diff options
author | Lucas Hoffmann <l-m-h@web.de> | 2016-12-29 16:25:05 +0100 |
---|---|---|
committer | Lucas Hoffmann <l-m-h@web.de> | 2017-01-10 08:56:26 +0100 |
commit | 5d88264efcf2e2ad846ed92d5578288435c4d26e (patch) | |
tree | 7b7ec5e6a1e19e6682691424b151f6b9e1dd2225 /alot/__main__.py | |
parent | 2d7d048f3e2eb33b20944d307a998abe09f2329b (diff) |
Simplify finding of config file
Especially let the command line parser check if a file given on the command
line exists.
Diffstat (limited to 'alot/__main__.py')
-rw-r--r-- | alot/__main__.py | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/alot/__main__.py b/alot/__main__.py index de46a727..c7114c8c 100644 --- a/alot/__main__.py +++ b/alot/__main__.py @@ -78,17 +78,14 @@ def main(): filemode='w', format=logformat) # locate alot config files - configfiles = [ - os.path.join(os.environ.get('XDG_CONFIG_HOME', - os.path.expanduser('~/.config')), - 'alot', 'config'), - ] - if options.config: - expanded_path = os.path.expanduser(options.config) - if not os.path.exists(expanded_path): - msg = 'Config file "%s" does not exist. Goodbye for now.' - sys.exit(msg % expanded_path) - configfiles.insert(0, expanded_path) + if options.config is None: + alotconfig = os.path.join( + os.environ.get('XDG_CONFIG_HOME', os.path.expanduser('~/.config')), + 'alot', 'config') + if not os.path.exists(alotconfig): + alotconfig = None + else: + alotconfig = options.config # locate notmuch config notmuchpath = os.environ.get('NOTMUCH_CONFIG', '~/.notmuch-config') @@ -96,13 +93,6 @@ def main(): notmuchpath = options.notmuch_config notmuchconfig = os.path.expanduser(notmuchpath) - alotconfig = None - # read the first alot config file we find - for configfilename in configfiles: - if os.path.exists(configfilename): - alotconfig = configfilename - break # use only the first - try: settings.read_config(alotconfig) settings.read_notmuch_config(notmuchconfig) |