Update vendored pyxdg to 0.28

This commit is contained in:
Labrys of Knossos 2022-11-28 06:15:51 -05:00
commit 5073ec0c6f
7 changed files with 95 additions and 66 deletions

View file

@ -43,6 +43,9 @@ xdg_config_dirs = [xdg_config_home] + \
xdg_cache_home = os.environ.get('XDG_CACHE_HOME') or \
os.path.join(_home, '.cache')
xdg_state_home = os.environ.get('XDG_STATE_HOME') or \
os.path.join(_home, '.local', 'state')
xdg_data_dirs = [x for x in xdg_data_dirs if x]
xdg_config_dirs = [x for x in xdg_config_dirs if x]
@ -81,6 +84,17 @@ def save_cache_path(*resource):
os.makedirs(path)
return path
def save_state_path(*resource):
"""Ensure ``$XDG_STATE_HOME/<resource>/`` exists, and return its path.
'resource' should normally be the name of your application or a shared
resource."""
resource = os.path.join(*resource)
assert not resource.startswith('/')
path = os.path.join(xdg_state_home, resource)
if not os.path.isdir(path):
os.makedirs(path)
return path
def load_config_paths(*resource):
"""Returns an iterator which gives each directory named 'resource' in the
configuration search path. Information provided by earlier directories should