Clean up argument handling in get_standard_dir
This commit is contained in:
parent
b20536d472
commit
3a66937205
@ -177,14 +177,24 @@ def get_standard_dir(typ, args=None):
|
|||||||
args: An argparse namespace which could be used to override the
|
args: An argparse namespace which could be used to override the
|
||||||
locations.
|
locations.
|
||||||
"""
|
"""
|
||||||
|
# First check if it's been overridden
|
||||||
|
typ_to_argparse_arg = {
|
||||||
|
QStandardPaths.ConfigLocation: 'confdir'
|
||||||
|
}
|
||||||
if args is not None:
|
if args is not None:
|
||||||
if typ == QStandardPaths.ConfigLocation:
|
try:
|
||||||
if args.confdir is None:
|
argname = typ_to_argparse_arg[typ]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
arg_value = getattr(args, argname)
|
||||||
|
if arg_value is None:
|
||||||
pass
|
pass
|
||||||
elif args.confdir == '':
|
elif arg_value == '':
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
return args.confdir
|
return arg_value
|
||||||
|
# If not, get it from Qt
|
||||||
qapp = QCoreApplication.instance()
|
qapp = QCoreApplication.instance()
|
||||||
orgname = qapp.organizationName()
|
orgname = qapp.organizationName()
|
||||||
# We need to temporarily unset the organisationname here since the
|
# We need to temporarily unset the organisationname here since the
|
||||||
|
Loading…
Reference in New Issue
Block a user