-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change order of list returned by config_dirs() #168
base: main
Are you sure you want to change the base?
Conversation
Ignore all non-absolute paths found in XDG_CONFIG_HOME or XDG_CONFIG_DIRS
Actually, I think the correct behaviour (per the specification) is to use '~/.config' only if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coming from the beets issue you opened (but not the one I'm searching for) and I wanted to particularly point out the issue with XDG behavior on MacOS. The rest is 100% pedantic. Hope this helps - if not, feel free to ignore me, a random guy who has never before contributed to the confuse
code...
and UNIX_DIR_FALLBACK otherwise | ||
""" | ||
config_path = os.getenv('XDG_CONFIG_HOME', UNIX_DIR_FALLBACK) | ||
return config_path if config_path != '' else UNIX_DIR_FALLBACK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty string is falsy. Use as a boolean.
return config_path if config_path != '' else UNIX_DIR_FALLBACK | |
return config_path or UNIX_DIR_FALLBACK |
if 'XDG_CONFIG_HOME' in os.environ: | ||
paths.append(os.environ['XDG_CONFIG_HOME']) | ||
if 'XDG_CONFIG_DIRS' in os.environ: | ||
if 'XDG_CONFIG_DIRS' in os.environ and os.environ['XDG_CONFIG_DIRS'] != '': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to look before leap here, just use the default fallback behavior (will return None
if not present and empty string is falsy):
if 'XDG_CONFIG_DIRS' in os.environ and os.environ['XDG_CONFIG_DIRS'] != '': | |
if os.environ.get('XDG_CONFIG_DIRS'): |
@@ -155,7 +161,7 @@ def config_dirs(): | |||
paths = [] | |||
|
|||
if platform.system() == 'Darwin': | |||
paths.append(UNIX_DIR_FALLBACK) | |||
paths.append(xdg_config_home()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XDG does not apply to Darwin. These files should end up somewhere in ~/Library
on that platform.
This should fix a bug where
beet
uses~/.config
instead ofXDG_CONFIG_HOME
.