aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2010-12-01 00:28:22 -0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2010-12-01 00:28:53 -0200
commitb2f177148cc34275980543187fcdf0781e3a52e2 (patch)
treea40663e0984b90bc3f221a96fb2bca5832d7b5eb
parentrewrote g_octave.config (diff)
downloadg-octave-b2f177148cc34275980543187fcdf0781e3a52e2.tar.gz
g-octave-b2f177148cc34275980543187fcdf0781e3a52e2.tar.bz2
g-octave-b2f177148cc34275980543187fcdf0781e3a52e2.zip
added g_octave.info, small fixes
-rw-r--r--g_octave/config.py6
-rw-r--r--g_octave/info.py48
2 files changed, 50 insertions, 4 deletions
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']