From 80d57d8006a5af2854efa195c49c6f5edd5f93b1 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Sun, 10 May 2015 21:14:09 +0200 Subject: Allow Parsing an extra File via Command-Line --- voctocore/lib/args.py | 3 ++- voctocore/lib/config.py | 14 ++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'voctocore') diff --git a/voctocore/lib/args.py b/voctocore/lib/args.py index 6699679..3f1f3df 100644 --- a/voctocore/lib/args.py +++ b/voctocore/lib/args.py @@ -9,7 +9,8 @@ parser.add_argument('-v', '--verbose', action='store_true', parser.add_argument('-c', '--color', action='store', choices=['auto', 'always', 'never'], default='auto', help="Control the use of colors in the Log-Output") -parser.add_argument('-i', '---config-ini', action='store', +parser.add_argument('-i', '--ini-file', action='store', help="Load a custom config.ini-File") + Args = parser.parse_args() diff --git a/voctocore/lib/config.py b/voctocore/lib/config.py index 88e713c..fdd2360 100644 --- a/voctocore/lib/config.py +++ b/voctocore/lib/config.py @@ -1,5 +1,6 @@ import os.path from configparser import SafeConfigParser +from lib.args import Args __all__ = ['Config'] @@ -8,9 +9,14 @@ def getlist(self, section, option): SafeConfigParser.getlist = getlist -Config = SafeConfigParser() -Config.read([ +files = [ 'default-config.ini', '/etc/voctomix.ini', - os.path.expanduser('~/.voctomix.ini') -]) + os.path.expanduser('~/.voctomix.ini'), +] + +if Args.ini_file is not None: + files.append(Args.ini_file) + +Config = SafeConfigParser() +Config.read(files) -- cgit v1.2.3