From b20536d4724a27d45cf55d28105df21979439b46 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 2 Oct 2014 21:50:54 +0200 Subject: [PATCH] Move handling of --confdir into get_standard_dir --- qutebrowser/config/config.py | 7 +------ qutebrowser/utils/utils.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index 2dc6d15b7..97dc04e39 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -87,12 +87,7 @@ def init(args): Args: args: The argparse namespace. """ - if args.confdir is None: - confdir = utils.get_standard_dir(QStandardPaths.ConfigLocation) - elif args.confdir == '': - confdir = None - else: - confdir = args.confdir + confdir = utils.get_standard_dir(QStandardPaths.ConfigLocation, args) try: app = objreg.get('app') config_obj = ConfigManager(confdir, 'qutebrowser.conf', app) diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py index 7031f81ff..54814d9c1 100644 --- a/qutebrowser/utils/utils.py +++ b/qutebrowser/utils/utils.py @@ -168,13 +168,23 @@ def pastebin(text): return url -def get_standard_dir(typ): +def get_standard_dir(typ, args=None): """Get the directory where files of the given type should be written to. Args: typ: A member of the QStandardPaths::StandardLocation enum, see http://qt-project.org/doc/qt-5/qstandardpaths.html#StandardLocation-enum + args: An argparse namespace which could be used to override the + locations. """ + if args is not None: + if typ == QStandardPaths.ConfigLocation: + if args.confdir is None: + pass + elif args.confdir == '': + return None + else: + return args.confdir qapp = QCoreApplication.instance() orgname = qapp.organizationName() # We need to temporarily unset the organisationname here since the