aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2010-12-09 17:17:22 -0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2010-12-09 17:17:22 -0200
commit56ffccf741b9a8db0637dc0901d319faf07aa81a (patch)
treea55300151448844fe4ef0bcaa4d63ba97513f2f8
parentfixed error message (diff)
downloadg-octave-56ffccf741b9a8db0637dc0901d319faf07aa81a.tar.gz
g-octave-56ffccf741b9a8db0637dc0901d319faf07aa81a.tar.bz2
g-octave-56ffccf741b9a8db0637dc0901d319faf07aa81a.zip
fixed stuff to use the new config object
-rw-r--r--g_octave/checksum.py2
-rw-r--r--g_octave/config.py4
-rw-r--r--g_octave/description.py28
-rw-r--r--g_octave/description_tree.py13
-rw-r--r--g_octave/fetch.py2
-rw-r--r--g_octave/log.py2
-rw-r--r--g_octave/overlay.py3
-rw-r--r--g_octave/package_manager.py2
-rwxr-xr-xscripts/g-octave3
9 files changed, 25 insertions, 34 deletions
diff --git a/g_octave/checksum.py b/g_octave/checksum.py
index c5ead44..7a55499 100644
--- a/g_octave/checksum.py
+++ b/g_octave/checksum.py
@@ -24,7 +24,7 @@ import json
import os
from .config import Config
-config = Config(True)
+config = Config()
def sha1_compute(filename):
diff --git a/g_octave/config.py b/g_octave/config.py
index 246d48f..b0362cf 100644
--- a/g_octave/config.py
+++ b/g_octave/config.py
@@ -57,10 +57,10 @@ 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'
+ # '/etc/g-octave.cfg', '../etc/g-octave.cfg'
available_files = [
- os.path.join(cwd, '..', 'etc', 'g-octave.cfg'),
os.path.join('/etc', 'g-octave.cfg'),
+ os.path.join(cwd, '..', 'etc', 'g-octave.cfg'),
]
# get the first one available
diff --git a/g_octave/description.py b/g_octave/description.py
index c0a3fe7..f1c8449 100644
--- a/g_octave/description.py
+++ b/g_octave/description.py
@@ -31,9 +31,10 @@ import tempfile
from contextlib import closing
from .config import Config
-from .exception import ConfigException, DescriptionException
from .compat import py3k
from .checksum import sha1_compute
+from .exception import DescriptionException
+from .info import Info
if py3k:
import urllib.request as urllib
@@ -43,6 +44,8 @@ else:
from .log import Log
log = Log('g_octave.description')
+conf = Config()
+
# octave-forge DESCRIPTION's dependencies atoms
re_depends = re.compile(r'^([a-zA-Z0-9-]+) *(\( *([><=]?=?) *([0-9.]+) *\))?')
@@ -51,13 +54,9 @@ re_pkg_atom = re.compile(r'^(.+)-([0-9.]+)$')
class Description(object):
- def __init__(self, file, conf=None, parse_sysreq=True):
+ def __init__(self, file, parse_sysreq=True):
log.info('Parsing file: %s' % file)
-
- if conf is None:
- conf = Config()
- self._config = conf
if not os.path.exists(file):
log.error('File not found: %s' % file)
@@ -65,6 +64,8 @@ class Description(object):
self._file = file
+ self._info = Info(os.path.join(conf.db, 'info.json'))
+
# dictionary with the parsed content of the DESCRIPTION file
self._desc = dict()
@@ -151,7 +152,7 @@ class Description(object):
# license
if key == 'license':
try:
- new_license = self._config.licenses.get(self._desc['license'])
+ new_license = self._info.licenses.get(self._desc['license'])
except:
new_license = ''
if new_license not in [None, '']:
@@ -194,20 +195,15 @@ class Description(object):
else:
atom += comparator
- try:
- conf_dependencies = self._config.dependencies
- except ConfigException:
- conf_dependencies = {}
-
# as octave is already in the portage tree, the atom is
# predefined.
if name.lower() == 'octave':
atom += 'sci-mathematics/octave'
- elif name in conf_dependencies:
- if conf_dependencies[name] == '':
+ elif name in self._info.dependencies:
+ if self._info.dependencies[name] == '':
continue
- atom += conf_dependencies[name]
+ atom += self._info.dependencies[name]
# the octave-forge packages will be put inside a "fake"
# category: g-octave
@@ -291,5 +287,5 @@ class SvnDescription(Description):
shutil.copyfileobj(fp, fp_)
except:
raise DescriptionException('Failed to fetch DESCRIPTION file from SVN')
- Description.__init__(self, temp_desc, parse_sysreq=True)
+ Description.__init__(self, temp_desc)
os.unlink(temp_desc)
diff --git a/g_octave/description_tree.py b/g_octave/description_tree.py
index 77be7f3..b719a5a 100644
--- a/g_octave/description_tree.py
+++ b/g_octave/description_tree.py
@@ -21,9 +21,9 @@ import re
from portage.versions import vercmp
-from .config import Config
+from .config import Config, ConfigException
from .description import *
-from .exception import ConfigException, DescriptionTreeException
+from .exception import DescriptionTreeException
from .log import Log
log = Log('g_octave.description_tree')
@@ -77,15 +77,10 @@ class DescriptionTree(object):
for desc_file in os.listdir(pkgdir):
pkg_p = desc_file[:-len('.DESCRIPTION')]
mypkg = re_pkg_atom.match(pkg_p)
- if mypkg == None:
+ if mypkg is None:
log.error('Invalid Atom: %s' % mypkg)
raise DescriptionTreeException('Invalid Atom: %s' % mypkg)
- try:
- blacklist = conf.blacklist
- except ConfigException:
- # blacklist isn't mandatory
- blacklist = []
- if mypkg.group(1) not in blacklist or not parse_sysreq:
+ if not parse_sysreq:
self.categories[mypkg.group(1)] = cat
self.pkg_list[cat].append({
'name': mypkg.group(1),
diff --git a/g_octave/fetch.py b/g_octave/fetch.py
index a0d7d5a..a78ed4b 100644
--- a/g_octave/fetch.py
+++ b/g_octave/fetch.py
@@ -18,7 +18,7 @@ from __future__ import absolute_import, print_function
__all__ = ['fetch']
from .config import Config
-conf = Config(True) # fetch phase
+conf = Config()
from .description_tree import DescriptionTree
from .exception import FetchException
diff --git a/g_octave/log.py b/g_octave/log.py
index 74b5f5d..8f393ca 100644
--- a/g_octave/log.py
+++ b/g_octave/log.py
@@ -18,7 +18,7 @@ import logging
import sys
from .config import Config
-conf = Config(fetch_phase=True)
+conf = Config()
class Log(object):
diff --git a/g_octave/overlay.py b/g_octave/overlay.py
index 79e832a..6433f2f 100644
--- a/g_octave/overlay.py
+++ b/g_octave/overlay.py
@@ -20,8 +20,7 @@ import sys
import shutil
import portage.output
-from .config import Config
-from .exception import ConfigException
+from .config import Config, ConfigException
from .compat import open
out = portage.output.EOutput()
diff --git a/g_octave/package_manager.py b/g_octave/package_manager.py
index a8a482a..14503ba 100644
--- a/g_octave/package_manager.py
+++ b/g_octave/package_manager.py
@@ -26,7 +26,7 @@ from g_octave.config import Config
from g_octave.ebuild import Ebuild
from g_octave.compat import open
-conf = Config(True)
+conf = Config()
class Base:
diff --git a/scripts/g-octave b/scripts/g-octave
index 89fb1d1..8951f43 100755
--- a/scripts/g-octave
+++ b/scripts/g-octave
@@ -208,7 +208,7 @@ def main():
from g_octave.config import Config
from g_octave.fetch import fetch
- conf_prefetch = Config(True)
+ conf_prefetch = Config()
if options.config:
try:
@@ -441,6 +441,7 @@ def main():
if __name__ == '__main__':
+ from g_octave.config import ConfigException
from g_octave.exception import *
return_code = os.EX_OK