Las siguientes líneas son un pequeño anticipo de lo que será libnhopkg, la librería básica de Nhopkg escrita en Python, tal y como anuncié en la entrada anterior.
Tan solo es el script y la clase encargados de obtener la información que necesitará Nhopkg para funcionar. Esta información la recoge, en primer lugar del sistema, datos como la arquitectura, la versión del kernle, etc. y por otro lado del archivo de configuración nhopkg.conf. Se trata de una parte muy básica de la librería, pero indispensable (creo yo) para seguir trabajando. Además, aunque no lo postee aquí, estoy trabajando en las clases necesarias para leer y obtener la información de los archivos nhoid, presentes en los paquetes.
Antes de nada también aprovecho para mostraros una plantilla (sin datos) de lo que será el archivo nhopkg.conf, con algunos cambios significativos desde la última versión estable. Aunque está bastante completo, no descarto que se le añadan más campos al archivo.
[main] sysconfdir = datadir = localstatedir = tmpdir = buildir = lockfile = [database] database = [server] server = [packaging] find_dirs = no_upgrade_file = [options] check_deps = check_inverse_deps = check_md5sum = verbose_mode = nls_support = nls_support_textdomain = nls_support_textdomaindir =
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Nhopkg is a universal package manager for unix systems.
# Copyright (C) 2009 Jaime Gil de Sagredo Luna <jaimegildesagredo@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Default Nhopkg configuration."""
import os
import ConfigParser
class config_parse:
"""Get data from Nhopkg configuration file."""
def __init__(self, config):
"""config: Nhopkg configuration file."""
self.config_file = config
(self.sysname, self.hostname, self.sysrelease, self.sysversion, \
self.machine) = os.uname()
self.read_file()
self.parse()
def read_file(self):
"""Read Nhopkg configuration file."""
self.config = ConfigParser.ConfigParser()
self.config.read(self.config_file)
def parse(self):
"""Parse Nhopkg configuration file."""
self.sysconfdir = self.config.get('main', 'sysconfdir')
self.datadir = self.config.get('main', 'datadir')
self.localstatedir = self.config.get('main', 'localstatedir')
self.tmpdir = self.config.get('main', 'tmpdir')
self.buildir = self.config.get('main', 'buildir')
self.lockfile = self.config.get('main', 'lockfile')
self.database = self.config.get('database', 'database')
self.server = self.config.get('server', 'server')
self.find_dirs = self.config.get('packaging', 'find_dirs')
self.no_upgrade_file = self.config.get('packaging', 'no_upgrade_file')
self.check_deps = self.config.get('options', 'check_deps')
self.check_inverse_deps = self.config.get('options', 'check_inverse_deps')
self.check_md5sum = self.config.get('options', 'check_md5sum')
self.verbose_mode = self.config.get('options', 'verbose_mode')
self.nls_support = self.config.get('options', 'nls_support')
self.nls_support_textdomain = self.config.get('options', \
'nls_support_textdomain')
self.nls_support_textdomaindir = self.config.get('options', \
'nls_support_textdomaindir')
En breve subiré las primeras líneas de este código al nuevo repositorio bazaar de Nhopkg, mucho más cómodo y en mi opinión mejor que el anterior svn. http://nhopkg.bzr.sourceforge.net/bzr/nhopkg/changes
Además la lista de correo de desarrollo de Nhopkg está ya activa, si quieres unirte al desarrollo o estar informado de las últimas novedades de éste, no dudes en suscribirte: https://lists.sourceforge.net/lists/listinfo/nhopkg-svn
