From 7a20fec52fd4d2b0b722816d6267c91ca9a10b00 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 24 Jul 2023 03:20:18 +0200 Subject: [PATCH] [#60] Added `--workdir` and `--logsdir` command-line options. Also, the application is now using `XDG_CONFIG_HOME` and `XDG_DATA_HOME` if available to lookup the configuration file and working directory. Closes: #60 --- platypush/config/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/platypush/config/__init__.py b/platypush/config/__init__.py index e11f81d3f..5b18b36f4 100644 --- a/platypush/config/__init__.py +++ b/platypush/config/__init__.py @@ -37,10 +37,12 @@ class Config: # Default config file locations: # - current directory + # - $XDG_CONFIG_HOME/platypush/config.yaml # - $HOME/.config/platypush/config.yaml # - /etc/platypush/config.yaml _cfgfile_locations = [ os.path.join(os.path.abspath('.'), 'config.yaml'), + os.path.join(os.environ.get('XDG_CONFIG_HOME', ''), 'config.yaml'), os.path.join(os.path.expanduser('~'), '.config', 'platypush', 'config.yaml'), os.path.join(os.sep, 'etc', 'platypush', 'config.yaml'), ] @@ -54,8 +56,13 @@ class Config: } _workdir_location = os.path.join( - os.path.expanduser('~'), '.local', 'share', 'platypush' + *( + (os.environ['XDG_DATA_HOME'], 'platypush') + if os.environ.get('XDG_DATA_HOME') + else (os.path.expanduser('~'), '.local', 'share', 'platypush') + ) ) + _included_files: Set[str] = set() def __init__(self, cfgfile: Optional[str] = None):