Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-xdg for openSUSE:Factory checked in at 2022-10-12 18:24:26 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-xdg (Old) and /work/SRC/openSUSE:Factory/.python-xdg.new.2275 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-xdg" Wed Oct 12 18:24:26 2022 rev:3 rq:1009872 version:5.1.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-xdg/python-xdg.changes 2020-11-12 22:37:37.178030799 +0100 +++ /work/SRC/openSUSE:Factory/.python-xdg.new.2275/python-xdg.changes 2022-10-12 18:25:57.921855423 +0200 @@ -1,0 +2,6 @@ +Tue Oct 11 17:22:17 UTC 2022 - Yogalakshmi Arunachalam <yarunacha...@suse.com> + +- Update to version 5.1.1 + * This patch release moves to using pathlib.Path.home() to get the home directory. + +------------------------------------------------------------------- Old: ---- xdg-5.0.0.tar.gz New: ---- xdg-5.1.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-xdg.spec ++++++ --- /var/tmp/diff_new_pack.57cgQ8/_old 2022-10-12 18:25:58.709857392 +0200 +++ /var/tmp/diff_new_pack.57cgQ8/_new 2022-10-12 18:25:58.717857412 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-xdg # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-xdg -Version: 5.0.0 +Version: 5.1.1 Release: 0 Summary: Variables defined by the XDG Base Directory Specification License: ISC ++++++ test_xdg.py ++++++ --- /var/tmp/diff_new_pack.57cgQ8/_old 2022-10-12 18:25:58.749857492 +0200 +++ /var/tmp/diff_new_pack.57cgQ8/_new 2022-10-12 18:25:58.753857501 +0200 @@ -24,8 +24,15 @@ assert xdg.xdg_cache_home() == HOME_DIR / ".cache" -def test_xdg_cache_home_set(monkeypatch: MonkeyPatch) -> None: - """Test xdg_cache_home when XDG_CACHE_HOME is set.""" +def test_xdg_cache_home_relative(monkeypatch: MonkeyPatch) -> None: + """Test xdg_cache_home when XDG_CACHE_HOME is relative path.""" + monkeypatch.setenv("HOME", os.fspath(HOME_DIR)) + monkeypatch.setenv("XDG_CACHE_HOME", "rela/tive") + assert xdg.xdg_cache_home() == HOME_DIR / ".cache" + + +def test_xdg_cache_home_absolute(monkeypatch: MonkeyPatch) -> None: + """Test xdg_cache_home when XDG_CACHE_HOME is absolute path.""" monkeypatch.setenv("XDG_CACHE_HOME", "/xdg_cache_home") assert xdg.xdg_cache_home() == Path("/xdg_cache_home") @@ -42,9 +49,15 @@ assert xdg.xdg_config_dirs() == [Path("/etc/xdg")] +def test_xdg_config_dirs_relative(monkeypatch: MonkeyPatch) -> None: + """Test xdg_config_dirs when XDG_CONFIG_DIRS is relative paths.""" + monkeypatch.setenv("XDG_CONFIG_DIRS", "rela/tive:ano/ther") + assert xdg.xdg_config_dirs() == [Path("/etc/xdg")] + + def test_xdg_config_dirs_set(monkeypatch: MonkeyPatch) -> None: """Test xdg_config_dirs when XDG_CONFIG_DIRS is set.""" - monkeypatch.setenv("XDG_CONFIG_DIRS", "/first:/sec/ond") + monkeypatch.setenv("XDG_CONFIG_DIRS", "/first:rela/tive:/sec/ond") assert xdg.xdg_config_dirs() == [Path("/first"), Path("/sec/ond")] @@ -62,8 +75,15 @@ assert xdg.xdg_config_home() == HOME_DIR / ".config" -def test_xdg_config_home_set(monkeypatch: MonkeyPatch) -> None: - """Test xdg_config_home when XDG_CONFIG_HOME is set.""" +def test_xdg_config_home_relative(monkeypatch: MonkeyPatch) -> None: + """Test xdg_config_home when XDG_CONFIG_HOME is relative path.""" + monkeypatch.setenv("HOME", os.fspath(HOME_DIR)) + monkeypatch.setenv("XDG_CONFIG_HOME", "rela/tive") + assert xdg.xdg_config_home() == HOME_DIR / ".config" + + +def test_xdg_config_home_absolute(monkeypatch: MonkeyPatch) -> None: + """Test xdg_config_home when XDG_CONFIG_HOME is absolute path.""" monkeypatch.setenv("XDG_CONFIG_HOME", "/xdg_config_home") assert xdg.xdg_config_home() == Path("/xdg_config_home") @@ -86,9 +106,18 @@ ] +def test_xdg_data_dirs_relative(monkeypatch: MonkeyPatch) -> None: + """Test xdg_data_dirs when XDG_DATA_DIRS is relative paths.""" + monkeypatch.setenv("XDG_DATA_DIRS", "rela/tive:ano/ther") + assert xdg.xdg_data_dirs() == [ + Path("/usr/local/share/"), + Path("/usr/share/"), + ] + + def test_xdg_data_dirs_set(monkeypatch: MonkeyPatch) -> None: """Test xdg_data_dirs when XDG_DATA_DIRS is set.""" - monkeypatch.setenv("XDG_DATA_DIRS", "/first/:/sec/ond/") + monkeypatch.setenv("XDG_DATA_DIRS", "/first/:rela/tive:/sec/ond/") assert xdg.xdg_data_dirs() == [Path("/first/"), Path("/sec/ond/")] @@ -106,8 +135,15 @@ assert xdg.xdg_data_home() == HOME_DIR / ".local" / "share" -def test_xdg_data_home_set(monkeypatch: MonkeyPatch) -> None: - """Test xdg_data_home when XDG_DATA_HOME is set.""" +def test_xdg_data_home_relative(monkeypatch: MonkeyPatch) -> None: + """Test xdg_data_home when XDG_DATA_HOME is relative path.""" + monkeypatch.setenv("HOME", os.fspath(HOME_DIR)) + monkeypatch.setenv("XDG_DATA_HOME", "rela/tive") + assert xdg.xdg_data_home() == HOME_DIR / ".local" / "share" + + +def test_xdg_data_home_absolute(monkeypatch: MonkeyPatch) -> None: + """Test xdg_data_home when XDG_DATA_HOME is absolute path.""" monkeypatch.setenv("XDG_DATA_HOME", "/xdg_data_home") assert xdg.xdg_data_home() == Path("/xdg_data_home") @@ -121,11 +157,44 @@ def test_xdg_runtime_dir_empty(monkeypatch: MonkeyPatch) -> None: """Test xdg_runtime_dir when XDG_RUNTIME_DIR is empty.""" monkeypatch.setenv("XDG_RUNTIME_DIR", "") - assert xdg.xdg_runtime_dir() == Path("") + assert xdg.xdg_runtime_dir() is None -def test_xdg_runtime_dir_set(monkeypatch: MonkeyPatch) -> None: - """Test xdg_runtime_dir when XDG_RUNTIME_DIR is set.""" +def test_xdg_runtime_dir_relative(monkeypatch: MonkeyPatch) -> None: + """Test xdg_runtime_dir when XDG_RUNTIME_DIR is relative path.""" + monkeypatch.setenv("XDG_RUNTIME_DIR", "rela/tive") + assert xdg.xdg_runtime_dir() is None + + +def test_xdg_runtime_dir_absolute(monkeypatch: MonkeyPatch) -> None: + """Test xdg_runtime_dir when XDG_RUNTIME_DIR is absolute path.""" monkeypatch.setenv("XDG_RUNTIME_DIR", "/xdg_runtime_dir") assert xdg.xdg_runtime_dir() == Path("/xdg_runtime_dir") + +def test_xdg_state_home_unset(monkeypatch: MonkeyPatch) -> None: + """Test xdg_state_home when XDG_STATE_HOME is unset.""" + monkeypatch.delenv("XDG_STATE_HOME", raising=False) + monkeypatch.setenv("HOME", os.fspath(HOME_DIR)) + assert xdg.xdg_state_home() == HOME_DIR / ".local" / "state" + + +def test_xdg_state_home_empty(monkeypatch: MonkeyPatch) -> None: + """Test xdg_state_home when XDG_STATE_HOME is empty.""" + monkeypatch.setenv("HOME", os.fspath(HOME_DIR)) + monkeypatch.setenv("XDG_STATE_HOME", "") + assert xdg.xdg_state_home() == HOME_DIR / ".local" / "state" + + +def test_xdg_state_home_relative(monkeypatch: MonkeyPatch) -> None: + """Test xdg_state_home when XDG_STATE_HOME is relative path.""" + monkeypatch.setenv("HOME", os.fspath(HOME_DIR)) + monkeypatch.setenv("XDG_STATE_HOME", "rela/tive") + assert xdg.xdg_state_home() == HOME_DIR / ".local" / "state" + + +def test_xdg_state_home_absolute(monkeypatch: MonkeyPatch) -> None: + """Test xdg_state_home when XDG_STATE_HOME is absolute path.""" + monkeypatch.setenv("XDG_STATE_HOME", "/xdg_state_home") + assert xdg.xdg_state_home() == Path("/xdg_state_home") + ++++++ xdg-5.0.0.tar.gz -> xdg-5.1.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xdg-5.0.0/LICENCE new/xdg-5.1.1/LICENCE --- old/xdg-5.0.0/LICENCE 2020-10-29 17:01:31.360000000 +0100 +++ new/xdg-5.1.1/LICENCE 2021-03-09 19:29:45.144121600 +0100 @@ -1,4 +1,4 @@ -Copyright ?? 2016-2020 Scott Stevenson <sc...@stevenson.io> +Copyright ?? 2016-2021 Scott Stevenson <sc...@stevenson.io> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xdg-5.0.0/PKG-INFO new/xdg-5.1.1/PKG-INFO --- old/xdg-5.0.0/PKG-INFO 2020-10-29 17:06:57.495794500 +0100 +++ new/xdg-5.1.1/PKG-INFO 2021-07-24 18:51:02.545209200 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: xdg -Version: 5.0.0 +Version: 5.1.1 Summary: Variables defined by the XDG Base Directory Specification Home-page: https://github.com/srstevenson/xdg License: ISC @@ -24,6 +24,13 @@ # xdg +[](https://github.com/srstevenson/xdg/blob/main/LICENCE) +[](https://github.com/srstevenson/xdg) +[](https://pypi.org/project/xdg/) +[](https://pypi.org/project/xdg/) +[](https://github.com/srstevenson/xdg/actions) +[](https://codecov.io/gh/srstevenson/xdg) + `xdg` is a Python module which provides functions to return paths to the directories defined by the [XDG Base Directory Specification][spec], to save you from duplicating the same snippet of logic in every Python utility you write @@ -35,9 +42,12 @@ To install the latest release from [PyPI], use [pip]: ```bash -python -m pip install xdg +python3 -m pip install xdg ``` +The latest release of `xdg` currently implements version 0.8 of the +specification, released on 8th May 2021. + In Python projects using [Poetry] or [Pipenv] for dependency management, add `xdg` as a dependency with `poetry add xdg` or `pipenv install xdg`. Alternatively, since `xdg` is only a single file you may prefer to just copy @@ -53,27 +63,30 @@ xdg_data_dirs, xdg_data_home, xdg_runtime_dir, + xdg_state_home, ) ``` -`xdg_cache_home()`, `xdg_config_home()`, and `xdg_data_home()` return -[`pathlib.Path` objects][path] containing the value of the environment variable -named `XDG_CACHE_HOME`, `XDG_CONFIG_HOME`, and `XDG_DATA_HOME` respectively, or -the default defined in the specification if the environment variable is unset or -empty. +`xdg_cache_home()`, `xdg_config_home()`, `xdg_data_home()`, and +`xdg_state_home()` return [`pathlib.Path` objects][path] containing the value of +the environment variable named `XDG_CACHE_HOME`, `XDG_CONFIG_HOME`, +`XDG_DATA_HOME`, and `XDG_STATE_HOME` respectively, or the default defined in +the specification if the environment variable is unset, empty, or contains a +relative path rather than absolute path. `xdg_config_dirs()` and `xdg_data_dirs()` return a list of `pathlib.Path` objects containing the value, split on colons, of the environment variable named `XDG_CONFIG_DIRS` and `XDG_DATA_DIRS` respectively, or the default defined in -the specification if the environment variable is unset or empty. +the specification if the environment variable is unset or empty. Relative paths +are ignored, as per the specification. `xdg_runtime_dir()` returns a `pathlib.Path` object containing the value of the `XDG_RUNTIME_DIR` environment variable, or `None` if the environment variable is -not set. +not set, or contains a relative path rather than absolute path. ## Copyright -Copyright ?? 2016-2020 [Scott Stevenson]. +Copyright ?? 2016-2021 [Scott Stevenson]. `xdg` is distributed under the terms of the [ISC licence]. @@ -84,5 +97,6 @@ [poetry]: https://python-poetry.org/ [pypi]: https://pypi.org/project/xdg/ [scott stevenson]: https://scott.stevenson.io -[spec]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html +[spec]: + https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xdg-5.0.0/README.md new/xdg-5.1.1/README.md --- old/xdg-5.0.0/README.md 2020-10-29 17:04:33.145000000 +0100 +++ new/xdg-5.1.1/README.md 2021-07-04 11:18:26.341441000 +0200 @@ -1,5 +1,12 @@ # xdg +[](https://github.com/srstevenson/xdg/blob/main/LICENCE) +[](https://github.com/srstevenson/xdg) +[](https://pypi.org/project/xdg/) +[](https://pypi.org/project/xdg/) +[](https://github.com/srstevenson/xdg/actions) +[](https://codecov.io/gh/srstevenson/xdg) + `xdg` is a Python module which provides functions to return paths to the directories defined by the [XDG Base Directory Specification][spec], to save you from duplicating the same snippet of logic in every Python utility you write @@ -11,9 +18,12 @@ To install the latest release from [PyPI], use [pip]: ```bash -python -m pip install xdg +python3 -m pip install xdg ``` +The latest release of `xdg` currently implements version 0.8 of the +specification, released on 8th May 2021. + In Python projects using [Poetry] or [Pipenv] for dependency management, add `xdg` as a dependency with `poetry add xdg` or `pipenv install xdg`. Alternatively, since `xdg` is only a single file you may prefer to just copy @@ -29,27 +39,30 @@ xdg_data_dirs, xdg_data_home, xdg_runtime_dir, + xdg_state_home, ) ``` -`xdg_cache_home()`, `xdg_config_home()`, and `xdg_data_home()` return -[`pathlib.Path` objects][path] containing the value of the environment variable -named `XDG_CACHE_HOME`, `XDG_CONFIG_HOME`, and `XDG_DATA_HOME` respectively, or -the default defined in the specification if the environment variable is unset or -empty. +`xdg_cache_home()`, `xdg_config_home()`, `xdg_data_home()`, and +`xdg_state_home()` return [`pathlib.Path` objects][path] containing the value of +the environment variable named `XDG_CACHE_HOME`, `XDG_CONFIG_HOME`, +`XDG_DATA_HOME`, and `XDG_STATE_HOME` respectively, or the default defined in +the specification if the environment variable is unset, empty, or contains a +relative path rather than absolute path. `xdg_config_dirs()` and `xdg_data_dirs()` return a list of `pathlib.Path` objects containing the value, split on colons, of the environment variable named `XDG_CONFIG_DIRS` and `XDG_DATA_DIRS` respectively, or the default defined in -the specification if the environment variable is unset or empty. +the specification if the environment variable is unset or empty. Relative paths +are ignored, as per the specification. `xdg_runtime_dir()` returns a `pathlib.Path` object containing the value of the `XDG_RUNTIME_DIR` environment variable, or `None` if the environment variable is -not set. +not set, or contains a relative path rather than absolute path. ## Copyright -Copyright ?? 2016-2020 [Scott Stevenson]. +Copyright ?? 2016-2021 [Scott Stevenson]. `xdg` is distributed under the terms of the [ISC licence]. @@ -60,4 +73,5 @@ [poetry]: https://python-poetry.org/ [pypi]: https://pypi.org/project/xdg/ [scott stevenson]: https://scott.stevenson.io -[spec]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html +[spec]: + https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xdg-5.0.0/pyproject.toml new/xdg-5.1.1/pyproject.toml --- old/xdg-5.0.0/pyproject.toml 2020-10-29 17:05:04.746000000 +0100 +++ new/xdg-5.1.1/pyproject.toml 2021-07-24 18:49:40.812924900 +0200 @@ -7,7 +7,7 @@ [tool.poetry] name = "xdg" -version = "5.0.0" +version = "5.1.1" description = "Variables defined by the XDG Base Directory Specification" authors = ["Scott Stevenson <sc...@stevenson.io>"] license = "ISC" @@ -28,14 +28,15 @@ python = "^3.6" [tool.poetry.dev-dependencies] -black = "=18.9b0" -flake8 = "^3.6" -isort = "^5.0.0" -mypy = "^0.782" -nox = "^2018.10" -pylint = "^2.6.0" -pytest = "^4.1" +black = "^20.8b1" +flake8 = "^3.9.2" +isort = "^5.8.0" +mypy = "^0.910" +nox = "^2021.6.12" +pylint = "^2.9.3" +pytest = "^6.2.4" +pytest-cov = "^2.12.1" [build-system] -requires = ["poetry>=0.12"] -build-backend = "poetry.masonry.api" +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xdg-5.0.0/setup.py new/xdg-5.1.1/setup.py --- old/xdg-5.0.0/setup.py 2020-10-29 17:06:57.495372000 +0100 +++ new/xdg-5.1.1/setup.py 2021-07-24 18:51:02.544717000 +0200 @@ -12,9 +12,9 @@ setup_kwargs = { 'name': 'xdg', - 'version': '5.0.0', + 'version': '5.1.1', 'description': 'Variables defined by the XDG Base Directory Specification', - 'long_description': '# xdg\n\n`xdg` is a Python module which provides functions to return paths to the\ndirectories defined by the [XDG Base Directory Specification][spec], to save you\nfrom duplicating the same snippet of logic in every Python utility you write\nthat deals with user cache, configuration, or data files. It has no external\ndependencies.\n\n## Installation\n\nTo install the latest release from [PyPI], use [pip]:\n\n```bash\npython -m pip install xdg\n```\n\nIn Python projects using [Poetry] or [Pipenv] for dependency management, add\n`xdg` as a dependency with `poetry add xdg` or `pipenv install xdg`.\nAlternatively, since `xdg` is only a single file you may prefer to just copy\n`src/xdg/__init__.py` from the source distribution into your project.\n\n## Usage\n\n```python\nfrom xdg import (\n xdg_cache_home,\n xdg_config_dirs,\n xdg_config_home,\n xdg_data_dirs,\n xdg_data_home,\n xdg_runtime_dir,\n)\n```\n\n`xdg_cache_home()`, `xdg_config_home( )`, and `xdg_data_home()` return\n[`pathlib.Path` objects][path] containing the value of the environment variable\nnamed `XDG_CACHE_HOME`, `XDG_CONFIG_HOME`, and `XDG_DATA_HOME` respectively, or\nthe default defined in the specification if the environment variable is unset or\nempty.\n\n`xdg_config_dirs()` and `xdg_data_dirs()` return a list of `pathlib.Path`\nobjects containing the value, split on colons, of the environment variable named\n`XDG_CONFIG_DIRS` and `XDG_DATA_DIRS` respectively, or the default defined in\nthe specification if the environment variable is unset or empty.\n\n`xdg_runtime_dir()` returns a `pathlib.Path` object containing the value of the\n`XDG_RUNTIME_DIR` environment variable, or `None` if the environment variable is\nnot set.\n\n## Copyright\n\nCopyright ?? 2016-2020 [Scott Stevenson].\n\n`xdg` is distributed under the terms of the [ISC licence].\n\n[isc licence]: https://opensource.org/licenses/ISC\n[path]: https://docs.python.org/3/library/pathlib.html# pathlib.Path\n[pip]: https://pip.pypa.io/en/stable/\n[pipenv]: https://docs.pipenv.org/\n[poetry]: https://python-poetry.org/\n[pypi]: https://pypi.org/project/xdg/\n[scott stevenson]: https://scott.stevenson.io\n[spec]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html\n', + 'long_description': '# xdg\n\n[](https://github.com/srstevenson/xdg/blob/main/LICENCE)\n[](https://github.com/srstevenson/xdg)\n[](https://pypi.org/project/xdg/)\n[](https://pypi.org/project/xdg/)\n[](https://github.com/srstevenson/xdg/actions)\n[](https://codecov.io/gh/srstevenson/xdg)\n\n`xdg` is a Python module which provides functions to return paths to the\ndirectories defined by the [XDG Base Directory Specification][spec], to save you\nfrom duplicating the same snippet of logic in every Python utility you write\nthat deals with user cache, configuration, or data files. It has no external\ndependencies.\n\n## Installation\n\nTo install the latest release from [PyPI], use [pip]:\n\n```bash\npython3 -m pip install xdg\n```\n\nThe latest release of `xdg` currently implements version 0.8 of the\nspecification, released on 8th May 2021.\n\nIn Python projects using [Poetry] or [Pipenv] for dependency management, add\n`xdg` as a dependency with `poetry add xdg` or `pipenv install xdg`.\nAlternatively, since `xdg` is only a single file you may prefer to just copy\n`src/xdg/__init__.py` from the source distribution into your project.\n\n## Usage\n\n```python\nfrom xdg import (\n xdg_cache_home,\n xdg_config_dirs,\n xdg_config_home,\n xdg_data_dirs,\n xdg_data_home,\n xdg_runtime_dir,\n xdg_state_home,\n)\n```\n\n`xdg_cache_home()`, `xdg_config_home()`, `xdg_data_home()`, and\n`xdg_state_home()` return [`pathlib.Path` objects][path] containing the value of\nthe environment variable nam ed `XDG_CACHE_HOME`, `XDG_CONFIG_HOME`,\n`XDG_DATA_HOME`, and `XDG_STATE_HOME` respectively, or the default defined in\nthe specification if the environment variable is unset, empty, or contains a\nrelative path rather than absolute path.\n\n`xdg_config_dirs()` and `xdg_data_dirs()` return a list of `pathlib.Path`\nobjects containing the value, split on colons, of the environment variable named\n`XDG_CONFIG_DIRS` and `XDG_DATA_DIRS` respectively, or the default defined in\nthe specification if the environment variable is unset or empty. Relative paths\nare ignored, as per the specification.\n\n`xdg_runtime_dir()` returns a `pathlib.Path` object containing the value of the\n`XDG_RUNTIME_DIR` environment variable, or `None` if the environment variable is\nnot set, or contains a relative path rather than absolute path.\n\n## Copyright\n\nCopyright ?? 2016-2021 [Scott Stevenson].\n\n`xdg` is distributed under the terms of the [ISC licence].\n\n[isc licence]: https://opensource.org/licen ses/ISC\n[path]: https://docs.python.org/3/library/pathlib.html#pathlib.Path\n[pip]: https://pip.pypa.io/en/stable/\n[pipenv]: https://docs.pipenv.org/\n[poetry]: https://python-poetry.org/\n[pypi]: https://pypi.org/project/xdg/\n[scott stevenson]: https://scott.stevenson.io\n[spec]:\n https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html\n', 'author': 'Scott Stevenson', 'author_email': 'sc...@stevenson.io', 'maintainer': None, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xdg-5.0.0/src/xdg/__init__.py new/xdg-5.1.1/src/xdg/__init__.py --- old/xdg-5.0.0/src/xdg/__init__.py 2020-10-29 17:04:33.182000000 +0100 +++ new/xdg-5.1.1/src/xdg/__init__.py 2021-07-23 20:27:38.262746800 +0200 @@ -1,4 +1,4 @@ -# Copyright ?? 2016-2020 Scott Stevenson <sc...@stevenson.io> +# Copyright ?? 2016-2021 Scott Stevenson <sc...@stevenson.io> # # Permission to use, copy, modify, and/or distribute this software for # any purpose with or without fee is hereby granted, provided that the @@ -16,21 +16,22 @@ """XDG Base Directory Specification variables. -xdg_cache_home(), xdg_config_home(), and xdg_data_home() return -pathlib.Path objects containing the value of the environment variable -named XDG_CACHE_HOME, XDG_CONFIG_HOME, and XDG_DATA_HOME respectively, -or the default defined in the specification if the environment variable -is unset or empty. +xdg_cache_home(), xdg_config_home(), xdg_data_home(), and xdg_state_home() +return pathlib.Path objects containing the value of the environment variable +named XDG_CACHE_HOME, XDG_CONFIG_HOME, XDG_DATA_HOME, and XDG_STATE_HOME +respectively, or the default defined in the specification if the environment +variable is unset, empty, or contains a relative path rather than absolute +path. xdg_config_dirs() and xdg_data_dirs() return a list of pathlib.Path objects containing the value, split on colons, of the environment variable named XDG_CONFIG_DIRS and XDG_DATA_DIRS respectively, or the default defined in the specification if the environment variable is -unset or empty. +unset or empty. Relative paths are ignored, as per the specification. xdg_runtime_dir() returns a pathlib.Path object containing the value of the XDG_RUNTIME_DIR environment variable, or None if the environment -variable is not set. +variable is not set, or contains a relative path rather than absolute path. """ @@ -47,6 +48,7 @@ "xdg_data_dirs", "xdg_data_home", "xdg_runtime_dir", + "xdg_state_home", "XDG_CACHE_HOME", "XDG_CONFIG_DIRS", "XDG_CONFIG_HOME", @@ -56,17 +58,13 @@ ] -def _home_dir() -> Path: - """Return a Path corresponding to the user's home directory.""" - return Path(os.path.expandvars("$HOME")) - - def _path_from_env(variable: str, default: Path) -> Path: """Read an environment variable as a path. The environment variable with the specified name is read, and its - value returned as a path. If the environment variable is not set, or - set to the empty string, the default value is returned. + value returned as a path. If the environment variable is not set, is + set to the empty string, or is set to a relative rather than + absolute path, the default value is returned. Parameters ---------- @@ -83,7 +81,7 @@ """ # TODO(srstevenson): Use assignment expression in Python 3.8. value = os.environ.get(variable) - if value: + if value and os.path.isabs(value): return Path(value) return default @@ -94,7 +92,8 @@ The environment variable with the specified name is read, and its value split on colons and returned as a list of paths. If the environment variable is not set, or set to the empty string, the - default value is returned. + default value is returned. Relative paths are ignored, as per the + specification. Parameters ---------- @@ -112,13 +111,17 @@ # TODO(srstevenson): Use assignment expression in Python 3.8. value = os.environ.get(variable) if value: - return [Path(path) for path in value.split(":")] + paths = [ + Path(path) for path in value.split(":") if os.path.isabs(path) + ] + if paths: + return paths return default def xdg_cache_home() -> Path: """Return a Path corresponding to XDG_CACHE_HOME.""" - return _path_from_env("XDG_CACHE_HOME", _home_dir() / ".cache") + return _path_from_env("XDG_CACHE_HOME", Path.home() / ".cache") def xdg_config_dirs() -> List[Path]: @@ -128,7 +131,7 @@ def xdg_config_home() -> Path: """Return a Path corresponding to XDG_CONFIG_HOME.""" - return _path_from_env("XDG_CONFIG_HOME", _home_dir() / ".config") + return _path_from_env("XDG_CONFIG_HOME", Path.home() / ".config") def xdg_data_dirs() -> List[Path]: @@ -141,7 +144,7 @@ def xdg_data_home() -> Path: """Return a Path corresponding to XDG_DATA_HOME.""" - return _path_from_env("XDG_DATA_HOME", _home_dir() / ".local" / "share") + return _path_from_env("XDG_DATA_HOME", Path.home() / ".local" / "share") def xdg_runtime_dir() -> Optional[Path]: @@ -151,10 +154,15 @@ returned as per the specification. """ - try: - return Path(os.environ["XDG_RUNTIME_DIR"]) - except KeyError: - return None + value = os.getenv("XDG_RUNTIME_DIR") + if value and os.path.isabs(value): + return Path(value) + return None + + +def xdg_state_home() -> Path: + """Return a Path corresponding to XDG_STATE_HOME.""" + return _path_from_env("XDG_STATE_HOME", Path.home() / ".local" / "state") # The following variables are deprecated, but remain for backward compatibility.