From 12ff5ac124e738d4603eb0ae0b6663462a1b33eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20H=C3=BCwe?= Date: Fri, 18 Jul 2008 12:08:03 +0000 Subject: [PATCH] - some cleanups/changes for the config handling: * extra-pkgs and urllist settings can be separated by a comma and/or whitespace: 'extra-pkgs: foo, bar xyz' * 'True', 'False' etc. are accepted values for boolean options --- osc/conf.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/osc/conf.py b/osc/conf.py index af36e914..a22cb5b2 100644 --- a/osc/conf.py +++ b/osc/conf.py @@ -252,6 +252,7 @@ def get_config(override_conffile = None, """do the actual work (see module documentation)""" import os import sys + import re global config conffile = override_conffile or os.environ.get('OSC_CONFIG', '~/.oscrc') @@ -297,22 +298,20 @@ def get_config(override_conffile = None, for i in boolean_opts: try: - if int(config.get(i)): - config[i] = True - else: - config[i] = False - except: - raise oscerr.ConfigError('option %s requires an integer value' % i) + config[i] = cp.getboolean('general', i) + except ValueError, e: + raise oscerr.ConfigError('cannot parse \'%s\' setting: ' % i + str(e)) config['packagecachedir'] = os.path.expanduser(config['packagecachedir']) - config['extra-pkgs'] = [ i.strip(',') for i in config['extra-pkgs'].split() ] + re_clist = re.compile('[, ]+') + config['extra-pkgs'] = [ i.strip() for i in re_clist.split(config['extra-pkgs'].strip()) ] if config['extra-pkgs'] == []: config['extra-pkgs'] = None # transform 'url1, url2, url3' form into a list if type(config['urllist']) == str: - config['urllist'] = [ i.strip() for i in config['urllist'].split(',') ] + config['urllist'] = [ i.strip() for i in re_clist.split(config['urllist'].strip()) ] # holds multiple usernames and passwords auth_dict = { }