Move handling of --confdir into get_standard_dir

This commit is contained in:
Florian Bruhin 2014-10-02 21:50:54 +02:00
parent 9e8ee00777
commit b20536d472
2 changed files with 12 additions and 7 deletions

View File

@ -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)

View File

@ -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