From b2f177148cc34275980543187fcdf0781e3a52e2 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Wed, 1 Dec 2010 00:28:22 -0200 Subject: added g_octave.info, small fixes --- g_octave/config.py | 6 ++---- g_octave/info.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 g_octave/info.py diff --git a/g_octave/config.py b/g_octave/config.py index 924bdb8..246d48f 100644 --- a/g_octave/config.py +++ b/g_octave/config.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- """ - config.py - ~~~~~~~~~ + g_octave.config + ~~~~~~~~~~~~~~~ This module implements a Python object to handle the configuration of g-octave. @@ -48,7 +48,6 @@ class Config(object): def __init__(self, config_file=None): - # config Parser self._config = configparser.ConfigParser(self._defaults) @@ -57,7 +56,6 @@ class Config(object): # no configuration file provided as parameter if config_file is None: - # we just want one of the following configuration files: # '../etc/g-octave.cfg', '/etc/g-octave.cfg' available_files = [ diff --git a/g_octave/info.py b/g_octave/info.py new file mode 100644 index 0000000..bd0ef08 --- /dev/null +++ b/g_octave/info.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +""" + g_octave.info + ~~~~~~~~~~~~~ + + This module implements a Python object to store the external dependencies + and the licenses as named on the gentoo-x86 tree. + + :copyright: (c) 2010 by Rafael Goncalves Martins + :license: GPL-2, see LICENSE for more details. +""" + +from __future__ import absolute_import +import json + +# py3k compatibility +from .compat import open + +__all__ = ['Info', 'InfoException'] + + +class InfoException(Exception): + pass + + +class Info(object): + + # dictionary with the dependencies + dependencies = {} + + # dictionary with the licenses + licenses = {} + + + def __init__(self, filename): + # try to read the file + from_json = {} + try: + with open(filename) as fp: + from_json = json.load(fp) + except: + raise InfoException('Failed to open file: %r' % filename) + else: + if 'dependencies' in from_json: + self.dependencies = from_json['dependencies'] + if 'licenses' in from_json: + self.licenses = from_json['licenses'] -- cgit v1.2.3-65-gdbad