diff options
author | Maxime “pep” Buquet <pep@bouah.net> | 2022-08-21 22:54:52 +0200 |
---|---|---|
committer | Maxime “pep” Buquet <pep@bouah.net> | 2022-08-23 11:44:11 +0200 |
commit | 62481f13295ad6b96648e608d4d93029864c8eef (patch) | |
tree | cc045510333cd278c9bfe58d1b8c17292a5c970f /poezio/xdg.py | |
parent | 10cc67e6c78ca37508ba30cba42baa68c8fff5a3 (diff) | |
download | poezio-roezio.tar.gz poezio-roezio.tar.bz2 poezio-roezio.tar.xz poezio-roezio.zip |
roezio: migrate poezio/xdg.pyroezio
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Diffstat (limited to 'poezio/xdg.py')
-rw-r--r-- | poezio/xdg.py | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/poezio/xdg.py b/poezio/xdg.py deleted file mode 100644 index d7ff9d73..00000000 --- a/poezio/xdg.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2018 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> -# -# This file is part of Poezio. -# -# Poezio is free software: you can redistribute it and/or modify -# it under the terms of the GPL-3.0+ license. See the COPYING file. -""" -Implements the XDG base directory specification. - -https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html -""" - -from pathlib import Path -from os import environ -from typing import Dict - -# $HOME has already been checked to not be None in test_env(). -DEFAULT_PATHS: Dict[str, Path] = { - 'XDG_CONFIG_HOME': Path.home() / '.config', - 'XDG_DATA_HOME': Path.home() / '.local' / 'share', - 'XDG_CACHE_HOME': Path.home() / '.cache', -} - - -def _get_directory(variable: str) -> Path: - """ - returns the default configuration directory path - """ - if variable not in DEFAULT_PATHS: - raise ValueError('Invalid XDG basedir variable') - xdg = environ.get(variable) - if xdg is not None: - xdg_path = Path(xdg) - if xdg_path.is_absolute(): - return xdg_path / 'poezio' - return DEFAULT_PATHS[variable] / 'poezio' - - -CONFIG_HOME = _get_directory('XDG_CONFIG_HOME') -DATA_HOME = _get_directory('XDG_DATA_HOME') -CACHE_HOME = _get_directory('XDG_CACHE_HOME') |