Skip to content

Commit

Permalink
Added entry in CHANGES.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
Dos Moonen committed Apr 12, 2022
1 parent 9309908 commit 5fdf122
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions keyring/util/platform_.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@


def _settings_root_XP():
return os.path.join(os.environ['USERPROFILE'], 'Local Settings')
return os.path.join(os.environ["USERPROFILE"], "Local Settings")


def _settings_root_Vista():
return os.environ.get('LOCALAPPDATA', os.environ.get('ProgramData', '.'))
return os.environ.get("LOCALAPPDATA", os.environ.get("ProgramData", "."))


def _data_root_Windows():
release, version, csd, ptype = platform.win32_ver()
root = _settings_root_XP() if release == 'XP' else _settings_root_Vista()
return os.path.join(root, 'Python Keyring')
root = _settings_root_XP() if release == "XP" else _settings_root_Vista()
return os.path.join(root, "Python Keyring")


def _data_root_Linux():
"""
Use freedesktop.org Base Dir Specification to determine storage
location.
"""
fallback = pathlib.Path.home() / '.local/share'
root = os.environ.get('XDG_DATA_HOME', None) or fallback
return os.path.join(root, 'python_keyring')
fallback = pathlib.Path.home() / ".local/share"
root = os.environ.get("XDG_DATA_HOME", None) or fallback
return os.path.join(root, "python_keyring")


_config_root_Windows = _data_root_Windows
Expand All @@ -39,9 +39,9 @@ def _check_old_config_root():
raise a RuntimeError to force the change.
"""
# disable the check - once is enough and avoids infinite loop
globals()['_check_old_config_root'] = lambda: None
config_file_new = os.path.join(_config_root_Linux(), 'keyringrc.cfg')
config_file_old = os.path.join(_data_root_Linux(), 'keyringrc.cfg')
globals()["_check_old_config_root"] = lambda: None
config_file_new = os.path.join(_config_root_Linux(), "keyringrc.cfg")
config_file_old = os.path.join(_data_root_Linux(), "keyringrc.cfg")
if os.path.isfile(config_file_old) and not os.path.isfile(config_file_new):
msg = (
"Keyring config exists only in the old location "
Expand All @@ -57,12 +57,12 @@ def _config_root_Linux():
location.
"""
_check_old_config_root()
fallback = pathlib.Path.home() / '.config'
key = 'XDG_CONFIG_HOME'
fallback = pathlib.Path.home() / ".config"
key = "XDG_CONFIG_HOME"
root = os.environ.get(key, None) or fallback
return os.path.join(root, 'python_keyring')
return os.path.join(root, "python_keyring")


# by default, use Unix convention
data_root = globals().get('_data_root_' + platform.system(), _data_root_Linux)
config_root = globals().get('_config_root_' + platform.system(), _config_root_Linux)
data_root = globals().get("_data_root_" + platform.system(), _data_root_Linux)
config_root = globals().get("_config_root_" + platform.system(), _config_root_Linux)

0 comments on commit 5fdf122

Please sign in to comment.