Skip to content

Commit

Permalink
Simplify and rewrite find_configuration_file
Browse files Browse the repository at this point in the history
  • Loading branch information
WhyNotHugo committed Jan 17, 2024
1 parent ff9ddc1 commit b6d90ca
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions khal/settings/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@
def find_configuration_file() -> Optional[str]:
"""Return the configuration filename.
This function builds the list of paths known by khal and then return the
first one which exists. The first paths searched are the ones described in
the XDG Base Directory Standard, e.g. ~/.config/khal/config.
Check all the paths for configuration files defined in the XDG Base Directory
Standard, and return the first one that exists, if any.
For the common case, this will return ~/.config/khal/config, assuming that it
exists.
"""
DEFAULT_PATH = __productname__

paths = [os.path.join(path, DEFAULT_PATH, 'config')
for path in xdg.BaseDirectory.xdg_config_dirs]
for path in paths:
for dir in xdg.BaseDirectory.xdg_config_dirs:
path = os.path.join(dir, __productname__, 'config')
if os.path.exists(path):
return path

Expand Down

0 comments on commit b6d90ca

Please sign in to comment.