Skip to content

Commit

Permalink
support xdg config file standard
Browse files Browse the repository at this point in the history
  • Loading branch information
NorthIsUp committed Jan 19, 2024
1 parent 6629dae commit 6bc5ebf
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions mackup/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@

from .constants import (
CUSTOM_APPS_DIR,
MACKUP_BACKUP_PATH,
MACKUP_CONFIG_FILE,
ENGINE_DROPBOX,
ENGINE_GDRIVE,
ENGINE_ICLOUD,
ENGINE_FS,
)

from .utils import (
error,
get_dropbox_folder_location,
Expand Down Expand Up @@ -143,7 +140,17 @@ def _setup_parser(self, filename=None):

# If we are not overriding the config filename
if not filename:
filename = MACKUP_CONFIG_FILE
if os.path.exists(MACKUP_CONFIG_FILE):
filename = MACKUP_CONFIG_FILE
elif "MACKUP_CONFIG_FILE" in os.environ:
filename = os.environ["MACKUP_CONFIG_FILE"]
elif "XDG_CONFIG_HOME" in os.environ:
filename = os.path.join(
os.environ["XDG_CONFIG_HOME"],
MACKUP_CONFIG_FILE.lstrip("."),
)
else:
filename = MACKUP_CONFIG_FILE

parser = configparser.ConfigParser(
allow_no_value=True, inline_comment_prefixes=(";", "#")
Expand Down

0 comments on commit 6bc5ebf

Please sign in to comment.