From 2019b245e8c370d5b55b3e99e0da319d6a35146f Mon Sep 17 00:00:00 2001 From: volpino Date: Sun, 2 Sep 2012 18:58:01 +0200 Subject: [PATCH] euscan: Adding config file support Signed-off-by: volpino --- TODO | 1 - bin/euscan | 3 ++- pym/euscan/__init__.py | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index 19126b4..4ed8061 100644 --- a/TODO +++ b/TODO @@ -17,7 +17,6 @@ euscan ### Misc -- Add a config file (/etc/euscan.conf, ~/.euscan.conf) - Add a HTTP cache (configurable) ### Tests diff --git a/bin/euscan b/bin/euscan index 76922d4..5d5e812 100755 --- a/bin/euscan +++ b/bin/euscan @@ -230,7 +230,8 @@ def parse_args(): def main(): """Parse command line and execute all actions.""" CONFIG['nocolor'] = ( - settings["NOCOLOR"] in ('yes', 'true') or not isatty + CONFIG['nocolor'] or + (settings["NOCOLOR"] in ('yes', 'true') or not isatty) ) if CONFIG['nocolor']: pp.output.nocolor() diff --git a/pym/euscan/__init__.py b/pym/euscan/__init__.py index dad6742..12c4a16 100644 --- a/pym/euscan/__init__.py +++ b/pym/euscan/__init__.py @@ -5,6 +5,10 @@ __version__ = "git" +import ConfigParser +import os + + CONFIG = { 'nocolor': False, 'quiet': False, @@ -27,6 +31,13 @@ CONFIG = { 'ebuild-uri': False, } +config = ConfigParser.ConfigParser() +config.read(['/etc/euscan.conf', os.path.expanduser('~/.euscan.conf')]) +if config.has_section("euscan"): + for key, value in config.items("euscan"): + if key in CONFIG: + CONFIG[key] = value + BLACKLIST_VERSIONS = [ # Compatibility package for running binaries linked against a # pre gcc 3.4 libstdc++, won't be updated