Projects
openEuler:Mainline
python-platformdirs
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 2
View file
_service:tar_scm:python-platformdirs.spec
Changed
@@ -1,13 +1,15 @@ %global _empty_manifest_terminate_build 0 Name: python-platformdirs -Version: 2.5.1 +Version: 3.5.0 Release: 1 Summary: A small Python module for determining appropriate platform-specific dirs License: MIT URL: https://github.com/platformdirs/platformdirs -Source0: https://files.pythonhosted.org/packages/33/66/61da40aa546141b0d70b37fe6bb4ef1200b4b4cb98849f131b58faa9a5d2/platformdirs-2.5.1.tar.gz -Patch0: 0001-fix-pkg-version.patch +Source0: https://files.pythonhosted.org/packages/91/17/3836ffe140abb245726d0e21c5b9b984e2569e7027c20d12e969ec69bd8a/platformdirs-3.5.0.tar.gz BuildArch: noarch + +BuildRequires: python3-pip python3-hatchling python3-hatch-vcs python3-wheel + %description The problem When writing desktop application, finding the right location to store user data and configuration varies per platform. Even for single-platform @@ -46,47 +48,30 @@ cp -r src/platformdirs ./ %build -%py3_build +%pyproject_build %install -%py3_install +%pyproject_install platformdirs==%{version} install -d -m755 %{buildroot}/%{_pkgdocdir} if -d doc ; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if -d docs ; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if -d example ; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if -d examples ; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi -pushd %{buildroot} -if -d usr/lib ; then - find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst -fi -if -d usr/lib64 ; then - find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst -fi -if -d usr/bin ; then - find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst -fi -if -d usr/sbin ; then - find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst -fi -touch doclist.lst -if -d usr/share/man ; then - find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst -fi -popd -mv %{buildroot}/filelist.lst . -mv %{buildroot}/doclist.lst . %check /usr/bin/pytest -%files -n python3-platformdirs -f filelist.lst -%dir %{python3_sitelib}/* +%files -n python3-platformdirs +%{python3_sitelib}/platformdirs* -%files help -f doclist.lst +%files help %{_docdir}/* %changelog +* Sat May 06 2023 xu_ping <707078654@qq.com> - 3.5.0-1 +- Upgrade the version to 3.5.0 + * Thu May 26 2022 OpenStack_SIG <openstack@openeuler.org> - 2.5.1-1 - Upgrade the version to 2.5.1
View file
_service:tar_scm:0001-fix-pkg-version.patch
Deleted
@@ -1,31 +0,0 @@ -From 8737b8d1f7727fa145fd858425e6552692a3b753 Mon Sep 17 00:00:00 2001 -From: yuqi <yuqi@isrc.iscas.ac.cn> -Date: Mon, 30 May 2022 12:37:51 +0000 -Subject: PATCH fix pkg version - ---- - setup.py | 10 +++++++++- - 1 file changed, 9 insertions(+), 1 deletion(-) - -diff --git a/setup.py b/setup.py -index a03590f..468a2f1 100644 ---- a/setup.py -+++ b/setup.py -@@ -1,5 +1,13 @@ - from __future__ import annotations -+import io -+import re -+ - - from setuptools import setup -+with io.open("src/platformdirs/version.py", "rt", encoding="utf8") as f: -+ version = re.search(r'''__version__ = '"(0-9.+)'"''', f.read()).group(1) - --setup() -+setup( -+ name="platformdirs", -+ version=version, -+ ) --- -2.33.0 -
View file
_service
Changed
@@ -2,7 +2,7 @@ <service name="tar_scm"> <param name="scm">git</param> <param name="url">git@gitee.com:src-openeuler/python-platformdirs.git</param> - <param name="revision">841b2a23dfd5c1d57e493ed7e58a5ab8c8b2bd8e</param> + <param name="revision">master</param> <param name="exclude">*</param> <param name="extract">*</param> </service>
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/.
Deleted
-(directory)
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/.github
Deleted
-(directory)
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/.github/CODEOWNERS
Deleted
@@ -1,1 +0,0 @@ -* @gaborbernat @ofek @Julian @RonnyPfannschmidt
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/.github/workflows
Deleted
-(directory)
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/.github/workflows/check.yml
Deleted
@@ -1,164 +0,0 @@ -name: check -on: - push: - pull_request: - schedule: - - cron: "0 8 * * *" - -concurrency: - group: check-${{ github.ref }} - cancel-in-progress: true - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - - uses: pre-commit/action@v2.0.3 - - test: - name: test ${{ matrix.py }} - ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - py: - - "3.10" - - "pypy-3.7-v7.3.7" # ahead to start it earlier because takes longer - - "3.9" - - "3.8" - - "3.7" - os: - - ubuntu-20.04 - - windows-2022 - - macos-10.15 - - steps: - - name: Setup python for tox - uses: actions/setup-python@v2 - with: - python-version: "3.10" - - name: Install tox - run: python -m pip install tox - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Setup python for test ${{ matrix.py }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.py }} - - name: Pick environment to run - run: | - import codecs - import os - import platform - import sys - cpy = platform.python_implementation() == "CPython" - base =("{}{}{}" if cpy else "{}{}").format("py" if cpy else "pypy", *sys.version_info0:2) - env = "TOXENV={}\n".format(base) - print("Picked:\n{}for{}".format(env, sys.version)) - with codecs.open(os.environ"GITHUB_ENV", "a", "utf-8") as file_handler: - file_handler.write(env) - shell: python - - name: Setup test suite - run: tox -vv --notest - - name: Run test suite - run: tox --skip-pkg-install - env: - PYTEST_ADDOPTS: "-vv --durations=20" - CI_RUN: "yes" - - name: Rename coverage report file - run: import os; import sys; os.rename(f".tox/.coverage.{os.environ'TOXENV'}", f".tox/.coverage.{os.environ'TOXENV'}-{sys.platform}") - shell: python - - name: Upload coverage data - uses: actions/upload-artifact@v2 - with: - name: coverage-data - path: ".tox/.coverage.*" - - coverage: - name: Combine coverage - runs-on: ubuntu-latest - needs: test - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - uses: actions/setup-python@v2 - with: - python-version: "3.10" - - name: Install tox - run: python -m pip install tox - - name: Setup coverage tool - run: tox -e coverage --notest - - name: Install package builder - run: python -m pip install build - - name: Build package - run: pyproject-build --wheel . - - name: Download coverage data - uses: actions/download-artifact@v2 - with: - name: coverage-data - path: .tox - - name: Combine and report coverage - run: tox -e coverage - - name: Upload HTML report - uses: actions/upload-artifact@v2 - with: - name: html-report - path: .tox/htmlcov - - check: - name: ${{ matrix.tox_env }} - ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: - - ubuntu-latest - - windows-latest - tox_env: - - dev - - type - - docs - - readme - exclude: - - { os: windows-latest, tox_env: readme } - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Setup Python "3.10" - uses: actions/setup-python@v2 - with: - python-version: "3.10" - - name: Install tox - run: python -m pip install tox - - name: Setup test suite - run: tox -vv --notest -e ${{ matrix.tox_env }} - - name: Run test suite - run: tox --skip-pkg-install -e ${{ matrix.tox_env }} - - publish: - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - needs: check, coverage, lint - runs-on: ubuntu-latest - steps: - - name: Setup python to build package - uses: actions/setup-python@v2 - with: - python-version: "3.10" - - name: Install build - run: python -m pip install build - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Build sdist and wheel - run: python -m build -s -w . -o dist - - name: Publish to PyPi - uses: pypa/gh-action-pypi-publish@master - with: - skip_existing: true - user: __token__ - password: ${{ secrets.pypi_password }}
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/.pre-commit-config.yaml
Deleted
@@ -1,58 +0,0 @@ -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.1.0 - hooks: - - id: check-ast - - id: check-builtin-literals - - id: check-docstring-first - - id: check-merge-conflict - - id: check-yaml - - id: check-toml - - id: debug-statements - - id: end-of-file-fixer - - id: trailing-whitespace - - repo: https://github.com/asottile/pyupgrade - rev: v2.31.0 - hooks: - - id: pyupgrade - args: "--py36-plus" - - repo: https://github.com/PyCQA/isort - rev: 5.10.1 - hooks: - - id: isort - - repo: https://github.com/psf/black - rev: 22.1.0 - hooks: - - id: black - args: --safe - - repo: https://github.com/asottile/blacken-docs - rev: v1.12.1 - hooks: - - id: blacken-docs - additional_dependencies: black==22.1.0 - - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.9.0 - hooks: - - id: rst-backticks - - repo: https://github.com/tox-dev/tox-ini-fmt - rev: "0.5.2" - hooks: - - id: tox-ini-fmt - args: "-p", "fix" - - repo: https://github.com/asottile/setup-cfg-fmt - rev: v1.20.0 - hooks: - - id: setup-cfg-fmt - args: --min-py3-version, "3.7", "--max-py-version", "3.10" - - repo: https://github.com/PyCQA/flake8 - rev: 4.0.1 - hooks: - - id: flake8 - additional_dependencies: - - flake8-bugbear==22.1.11 - - flake8-comprehensions==3.8 - - flake8-pytest-style==1.6 - - flake8-spellcheck==0.24 - - flake8-unused-arguments==0.0.9 - - flake8-noqa==1.2.1 - - pep8-naming==0.12.1
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/.readthedocs.yml
Deleted
@@ -1,18 +0,0 @@ -version: 2 -build: - image: latest -formats: - - htmlzip - - epub - - pdf -python: - version: 3.7 - install: - - method: pip - path: . - extra_requirements: - - docs -sphinx: - builder: html - configuration: docs/conf.py - fail_on_warning: true
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/CHANGES.rst
Deleted
@@ -1,145 +0,0 @@ -platformdirs Changelog -====================== - -platformdirs 2.5.1 ------------------- -- Add native support for nuitka - -platformdirs 2.5.0 ------------------- -- Add support for Termux subsystems - -platformdirs 2.4.1 ------------------- -- Drop python 3.6 support - -platformdirs 2.4.0 ------------------- -- Add ``user_documents_dir`` - -platformdirs 2.3.0 ------------------- -- Add ``user_runtime_dir`` and its path-returning equivalent (#37) - -platformdirs 2.2.0 ------------------- -- Unix: Fallback to default if XDG environment variable is empty - -platformdirs 2.1.0 ------------------- -- Add ``readthedocs.org`` documentation via Sphinx -- Modernize project layout -- Drop Python 2.7 and 3.5 support -- Android support -- Add type annotations -- Reorganize project layout to platform specific classes, see - :class:`PlatformDirsABC <platformdirs.api.PlatformDirsABC>` and it's implementations: - :class:`Android <platformdirs.android.Android>`, :class:`MacOS <platformdirs.macos.MacOS>`, - :class:`Unix <platformdirs.unix.Unix>` and :class:`Windows <platformdirs.windows.Windows>` -- Add ``*_path`` API, returning :class:`pathlib.Path <pathlib.Path>` objects instead of :class:`str` - (``user_data_path``, ``user_config_path``, ``user_cache_path``, ``user_state_path``, ``user_log_path``, - ``site_data_path``, ``site_config_path``) - by `@papr <https://github.com/papr/>`_ - -platformdirs 2.0.2 ------------------- -- Fix ``__version__`` and ``__version_info__`` - -platformdirs 2.0.1 ------------------- -- Documentation fixes - -platformdirs 2.0.0 ------------------- - -- **BREAKING** Name change as part of the friendly fork -- **BREAKING** Remove support for end-of-life Pythons 2.6, 3.2, and 3.3 -- **BREAKING** Correct the config directory on OSX/macOS -- Add Python 3.7, 3.8, and 3.9 support - -appdirs 1.4.4 -------------- -- PR #92 Don't import appdirs from setup.py which resolves issue #91 - -Project officially classified as Stable which is important -for inclusion in other distros such as ActivePython. - -appdirs 1.4.3 -------------- -- PR #76 Python 3.6 invalid escape sequence deprecation fixes -- Fix for Python 3.6 support - -appdirs 1.4.2 -------------- -- PR #84 Allow installing without setuptools -- PR #86 Fix string delimiters in setup.py description -- Add Python 3.6 support - -appdirs 1.4.1 -------------- -- issue #38 Fix _winreg import on Windows Py3 -- issue #55 Make appname optional - -appdirs 1.4.0 -------------- -- PR #42 AppAuthor is now optional on Windows -- issue 41 Support Jython on Windows, Mac, and Unix-like platforms. Windows - support requires `JNA <https://github.com/twall/jna>`_. -- PR #44 Fix incorrect behaviour of the site_config_dir method - -appdirs 1.3.0 -------------- -- Unix, issue 16 Conform to XDG standard, instead of breaking it for - everybody -- Unix Removes gratuitous case mangling of the case, since \*nix-es are - usually case sensitive, so mangling is not wise -- Unix Fixes the utterly wrong behaviour in ``site_data_dir``, return result - based on XDG_DATA_DIRS and make room for respecting the standard which - specifies XDG_DATA_DIRS is a multiple-value variable -- Issue 6 Add ``*_config_dir`` which are distinct on nix-es, according to - XDG specs; on Windows and Mac return the corresponding ``*_data_dir`` - -appdirs 1.2.0 -------------- - -- Unix Put ``user_log_dir`` under the *cache* dir on Unix. Seems to be more - typical. -- issue 9 Make ``unicode`` work on py3k. - -appdirs 1.1.0 -------------- - -- issue 4 Add ``AppDirs.user_log_dir``. -- Unix, issue 2, issue 7 appdirs now conforms to `XDG base directory spec - <https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_. -- Mac, issue 5 Fix ``site_data_dir()`` on Mac. -- Mac Drop use of 'Carbon' module in favour of hardcoded paths; supports - Python3 now. -- Windows Append "Cache" to ``user_cache_dir`` on Windows by default. Use - ``opinion=False`` option to disable this. -- Add ``appdirs.AppDirs`` convenience class. Usage: - - >>> dirs = AppDirs("SuperApp", "Acme", version="1.0") - >>> dirs.user_data_dir - '/Users/trentm/Library/Application Support/SuperApp/1.0' - -- Windows Cherry-pick Komodo's change to downgrade paths to the Windows short - paths if there are high bit chars. -- Linux Change default ``user_cache_dir()`` on Linux to be singular, e.g. - "~/.superapp/cache". -- Windows Add ``roaming`` option to ``user_data_dir()`` (for use on Windows only) - and change the default ``user_data_dir`` behaviour to use a *non*-roaming - profile dir (``CSIDL_LOCAL_APPDATA`` instead of ``CSIDL_APPDATA``). Why? Because - a large roaming profile can cause login speed issues. The "only syncs on - logout" behaviour can cause surprises in appdata info. - - -appdirs 1.0.1 (never released) ------------------------------- - -Started this changelog 27 July 2010. Before that this module originated in the -`Komodo <https://www.activestate.com/komodo-ide>`_ product as ``applib.py`` and then -as `applib/location.py -<https://github.com/ActiveState/applib/blob/master/applib/location.py>`_ (used by -`PyPM <https://code.activestate.com/pypm/>`_ in `ActivePython -<https://www.activestate.com/activepython>`_). This is basically a fork of -applib.py 1.0.1 and applib/location.py 1.0.1.
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/LICENSE.txt
Deleted
@@ -1,22 +0,0 @@ -# This is the MIT license - -Copyright (c) 2010 ActiveState Software Inc. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/codecov.yml
Deleted
@@ -1,6 +0,0 @@ -coverage: - status: - patch: - default: - informational: true -comment: false
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/docs
Deleted
-(directory)
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/docs/api.rst
Deleted
@@ -1,99 +0,0 @@ -API -=== - -User directories -~~~~~~~~~~~~~~~~ - -These are user-specific (and, generally, user-writeable) directories. - -User data directory -------------------- - -.. autofunction:: platformdirs.user_data_dir -.. autofunction:: platformdirs.user_data_path - -User config directory ---------------------- - -.. autofunction:: platformdirs.user_config_dir -.. autofunction:: platformdirs.user_config_path - -Cache directory -------------------- - -.. autofunction:: platformdirs.user_cache_dir -.. autofunction:: platformdirs.user_cache_path - -State directory -------------------- - -.. autofunction:: platformdirs.user_state_dir -.. autofunction:: platformdirs.user_state_path - -Logs directory -------------------- - -.. autofunction:: platformdirs.user_log_dir -.. autofunction:: platformdirs.user_log_path - -User documents directory ------------------------- - -.. autofunction:: platformdirs.user_documents_dir -.. autofunction:: platformdirs.user_documents_path - -Runtime directory -------------------- - -.. autofunction:: platformdirs.user_runtime_dir -.. autofunction:: platformdirs.user_runtime_path - -Shared directories -~~~~~~~~~~~~~~~~~~ - -These are system-wide (and, generally, read-only) directories. - -Shared data directory ---------------------- - -.. autofunction:: platformdirs.site_data_dir -.. autofunction:: platformdirs.site_data_path - -Shared config directory ------------------------ - -.. autofunction:: platformdirs.site_config_dir -.. autofunction:: platformdirs.site_config_path - -Platforms -~~~~~~~~~ - -ABC ---- -.. autoclass:: platformdirs.api.PlatformDirsABC - :members: - :special-members: __init__ - -Android -------- -.. autoclass:: platformdirs.android.Android - :members: - :show-inheritance: - -macOS ------ -.. autoclass:: platformdirs.macos.MacOS - :members: - :show-inheritance: - -Unix (Linux) ------------- -.. autoclass:: platformdirs.unix.Unix - :members: - :show-inheritance: - -Windows -------- -.. autoclass:: platformdirs.windows.Windows - :members: - :show-inheritance:
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/docs/changelog.rst
Deleted
@@ -1,1 +0,0 @@ -.. include:: ../CHANGES.rst
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/docs/conf.py
Deleted
@@ -1,26 +0,0 @@ -from __future__ import annotations - -from platformdirs.version import __version__ - -author = "The platformdirs team" -project = "platformdirs" -copyright = "2021, The platformdirs team" - -release = __version__ -version = release -extensions = - "sphinx.ext.autodoc", - "sphinx.ext.autosectionlabel", - "sphinx.ext.viewcode", - "sphinx.ext.intersphinx", - # "sphinx_autodoc_typehints", - -html_theme = "furo" - -autodoc_default_options = { - "member-order": "bysource", - "undoc-members": True, -} -default_role = "any" -autodoc_typehints = "signature" -intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/docs/index.rst
Deleted
@@ -1,23 +0,0 @@ -platformdirs's documentation -============================ - -``platformdirs`` is a library to determine platform-specific system directories. -This includes directories where to place cache files, user data, configuration, -etc. - -The source code and issue tracker are both hosted on `GitHub`_. - -.. _GitHub: https://github.com/platformdirs/platformdirs - -.. toctree:: - :maxdepth: 3 - - api - changelog - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search`
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/setup.cfg
Deleted
@@ -1,108 +0,0 @@ -metadata -name = platformdirs -description = A small Python module for determining appropriate platform-specific dirs, e.g. a "user data dir". -long_description = file: README.rst -long_description_content_type = text/x-rst -url = https://github.com/platformdirs/platformdirs -maintainer = Bernát Gábor, Julian Berman, Ofek Lev, Ronny Pfannschmidt -maintainer_email = gaborjbernat@gmail.com, Julian@GrayVines.com, oss@ofek.dev, opensource@ronnypfannschmidt.de -license = MIT -license_file = LICENSE.txt -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - License :: OSI Approved :: MIT License - Operating System :: OS Independent - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: Implementation :: CPython - Programming Language :: Python :: Implementation :: PyPy - Topic :: Software Development :: Libraries :: Python Modules -keywords = application directory log cache user -project_urls = - Source=https://github.com/platformdirs/platformdirs - Tracker=https://github.com/platformdirs/platformdirs/issues - Documentation=https://platformdirs.readthedocs.io/ - -options -packages = find: -python_requires = >=3.7 -package_dir = - =src -zip_safe = True - -options.packages.find -where = src - -options.extras_require -docs = - Sphinx>=4 - furo>=2021.7.5b38 - proselint>=0.10.2 - sphinx-autodoc-typehints>=1.12 -test = - appdirs==1.4.4 - pytest>=6 - pytest-cov>=2.7 - pytest-mock>=3.6 - -options.package_data -platformdirs = py.typed - -flake8 -max-line-length = 120 -dictionaries = en_US,python,technical - -coverage:report -show_missing = True -exclude_lines = - \#\s*pragma: no cover - ^\s*raise AssertionError\b - ^\s*raise NotImplementedError\b - ^\s*raise$ - ^if __name__ == '"__main__'":$ - -coverage:paths -source = - src - .tox/*/lib/python*/site-packages - .tox/pypy*/site-packages - .tox\*\Lib\site-packages\ - */src - *\src -other = - . - */platformdirs - *\platformdirs - -coverage:run -branch = true -parallel = true -dynamic_context = test_function -source = - ${_COVERAGE_SRC} - -coverage:html -show_contexts = true -skip_covered = false -skip_empty = true - -mypy -python_version = 3.9 -warn_unused_ignores = False - -mypy-appdirs.* -ignore_missing_imports = True - -mypy-jnius.* -ignore_missing_imports = True - -egg_info -tag_build = -tag_date = 0 -
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/setup.py
Deleted
@@ -1,5 +0,0 @@ -from __future__ import annotations - -from setuptools import setup - -setup()
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/src
Deleted
-(directory)
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/src/platformdirs
Deleted
-(directory)
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/src/platformdirs.egg-info
Deleted
-(directory)
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/src/platformdirs.egg-info/PKG-INFO
Deleted
@@ -1,241 +0,0 @@ -Metadata-Version: 2.1 -Name: platformdirs -Version: 2.5.1 -Summary: A small Python module for determining appropriate platform-specific dirs, e.g. a "user data dir". -Home-page: https://github.com/platformdirs/platformdirs -Maintainer: Bernát Gábor, Julian Berman, Ofek Lev, Ronny Pfannschmidt -Maintainer-email: gaborjbernat@gmail.com, Julian@GrayVines.com, oss@ofek.dev, opensource@ronnypfannschmidt.de -License: MIT -Project-URL: Source, https://github.com/platformdirs/platformdirs -Project-URL: Tracker, https://github.com/platformdirs/platformdirs/issues -Project-URL: Documentation, https://platformdirs.readthedocs.io/ -Keywords: application directory log cache user -Platform: UNKNOWN -Classifier: Development Status :: 5 - Production/Stable -Classifier: Intended Audience :: Developers -Classifier: License :: OSI Approved :: MIT License -Classifier: Operating System :: OS Independent -Classifier: Programming Language :: Python -Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3 :: Only -Classifier: Programming Language :: Python :: 3.7 -Classifier: Programming Language :: Python :: 3.8 -Classifier: Programming Language :: Python :: 3.9 -Classifier: Programming Language :: Python :: 3.10 -Classifier: Programming Language :: Python :: Implementation :: CPython -Classifier: Programming Language :: Python :: Implementation :: PyPy -Classifier: Topic :: Software Development :: Libraries :: Python Modules -Requires-Python: >=3.7 -Description-Content-Type: text/x-rst -Provides-Extra: docs -Provides-Extra: test -License-File: LICENSE.txt - -The problem -=========== - -.. image:: https://github.com/platformdirs/platformdirs/workflows/Test/badge.svg - :target: https://github.com/platformdirs/platformdirs/actions?query=workflow%3ATest - -When writing desktop application, finding the right location to store user data -and configuration varies per platform. Even for single-platform apps, there -may by plenty of nuances in figuring out the right location. - -For example, if running on macOS, you should use:: - - ~/Library/Application Support/<AppName> - -If on Windows (at least English Win XP) that should be:: - - C:\Documents and Settings\<User>\Application Data\Local Settings\<AppAuthor>\<AppName> - -or possibly:: - - C:\Documents and Settings\<User>\Application Data\<AppAuthor>\<AppName> - -for `roaming profiles <https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-vista/cc766489(v=ws.10)>`_ but that is another story. - -On Linux (and other Unices), according to the `XDG Basedir Spec`_, it should be:: - - ~/.local/share/<AppName> - -.. _XDG Basedir Spec: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html - -``platformdirs`` to the rescue -============================== - -This kind of thing is what the ``platformdirs`` module is for. -``platformdirs`` will help you choose an appropriate: - -- user data dir (``user_data_dir``) -- user config dir (``user_config_dir``) -- user cache dir (``user_cache_dir``) -- site data dir (``site_data_dir``) -- site config dir (``site_config_dir``) -- user log dir (``user_log_dir``) -- user documents dir (``user_documents_dir``) -- user runtime dir (``user_runtime_dir``) - -And also: - -- Is a single module so other Python packages can vendor their own private copy. -- Is slightly opinionated on the directory names used. Look for "OPINION" in - documentation and code for when an opinion is being applied. - -Example output -============== - -On macOS: - -.. code-block:: pycon - - >>> from platformdirs import * - >>> appname = "SuperApp" - >>> appauthor = "Acme" - >>> user_data_dir(appname, appauthor) - '/Users/trentm/Library/Application Support/SuperApp' - >>> site_data_dir(appname, appauthor) - '/Library/Application Support/SuperApp' - >>> user_cache_dir(appname, appauthor) - '/Users/trentm/Library/Caches/SuperApp' - >>> user_log_dir(appname, appauthor) - '/Users/trentm/Library/Logs/SuperApp' - >>> user_documents_dir() - '/Users/trentm/Documents' - >>> user_runtime_dir(appname, appauthor) - '/Users/trentm/Library/Caches/TemporaryItems/SuperApp' - -On Windows 7: - -.. code-block:: pycon - - >>> from platformdirs import * - >>> appname = "SuperApp" - >>> appauthor = "Acme" - >>> user_data_dir(appname, appauthor) - 'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp' - >>> user_data_dir(appname, appauthor, roaming=True) - 'C:\\Users\\trentm\\AppData\\Roaming\\Acme\\SuperApp' - >>> user_cache_dir(appname, appauthor) - 'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp\\Cache' - >>> user_log_dir(appname, appauthor) - 'C:\\Users\\trentm\\AppData\\Local\\Acme\\SuperApp\\Logs' - >>> user_documents_dir() - 'C:\\Users\\trentm\\Documents' - >>> user_runtime_dir(appname, appauthor) - 'C:\\Users\\trentm\\AppData\\Local\\Temp\\Acme\\SuperApp' - -On Linux: - -.. code-block:: pycon - - >>> from platformdirs import * - >>> appname = "SuperApp" - >>> appauthor = "Acme" - >>> user_data_dir(appname, appauthor) - '/home/trentm/.local/share/SuperApp' - >>> site_data_dir(appname, appauthor) - '/usr/local/share/SuperApp' - >>> site_data_dir(appname, appauthor, multipath=True) - '/usr/local/share/SuperApp:/usr/share/SuperApp' - >>> user_cache_dir(appname, appauthor) - '/home/trentm/.cache/SuperApp' - >>> user_log_dir(appname, appauthor) - '/home/trentm/.cache/SuperApp/log' - >>> user_config_dir(appname) - '/home/trentm/.config/SuperApp' - >>> user_documents_dir() - '/home/trentm/Documents' - >>> user_runtime_dir(appname, appauthor) - '/run/user/{os.getuid()}/SuperApp' - >>> site_config_dir(appname) - '/etc/xdg/SuperApp' - >>> os.environ"XDG_CONFIG_DIRS" = "/etc:/usr/local/etc" - >>> site_config_dir(appname, multipath=True) - '/etc/SuperApp:/usr/local/etc/SuperApp' - -On Android:: - - >>> from platformdirs import * - >>> appname = "SuperApp" - >>> appauthor = "Acme" - >>> user_data_dir(appname, appauthor) - '/data/data/com.termux/files/SuperApp' - >>> user_cache_dir(appname, appauthor) - '/data/data/com.termux/cache/SuperApp' - >>> user_log_dir(appname, appauthor) - '/data/data/com.termux/cache/SuperApp/log' - >>> user_config_dir(appname) - '/data/data/com.termux/shared_prefs/SuperApp' - >>> user_documents_dir() - '/storage/emulated/0/Documents' - >>> user_runtime_dir(appname, appauthor) - '/data/data/com.termux/cache/SuperApp/tmp' - -``PlatformDirs`` for convenience -================================ - -.. code-block:: pycon - - >>> from platformdirs import PlatformDirs - >>> dirs = PlatformDirs("SuperApp", "Acme") - >>> dirs.user_data_dir - '/Users/trentm/Library/Application Support/SuperApp' - >>> dirs.site_data_dir - '/Library/Application Support/SuperApp' - >>> dirs.user_cache_dir - '/Users/trentm/Library/Caches/SuperApp' - >>> dirs.user_log_dir - '/Users/trentm/Library/Logs/SuperApp' - >>> dirs.user_documents_dir - '/Users/trentm/Documents' - >>> dirs.user_runtime_dir - '/Users/trentm/Library/Caches/TemporaryItems/SuperApp' - -Per-version isolation -===================== - -If you have multiple versions of your app in use that you want to be -able to run side-by-side, then you may want version-isolation for these -dirs:: - - >>> from platformdirs import PlatformDirs - >>> dirs = PlatformDirs("SuperApp", "Acme", version="1.0") - >>> dirs.user_data_dir - '/Users/trentm/Library/Application Support/SuperApp/1.0' - >>> dirs.site_data_dir - '/Library/Application Support/SuperApp/1.0' - >>> dirs.user_cache_dir - '/Users/trentm/Library/Caches/SuperApp/1.0' - >>> dirs.user_log_dir - '/Users/trentm/Library/Logs/SuperApp/1.0' - >>> dirs.user_documents_dir - '/Users/trentm/Documents' - >>> dirs.user_runtime_dir - '/Users/trentm/Library/Caches/TemporaryItems/SuperApp/1.0' - -Be wary of using this for configuration files though; you'll need to handle -migrating configuration files manually. - -Why this Fork? -============== - -This repository is a friendly fork of the wonderful work started by -`ActiveState <https://github.com/ActiveState/appdirs>`_ who created -``appdirs``, this package's ancestor. - -Maintaining an open source project is no easy task, particularly -from within an organization, and the Python community is indebted -to ``appdirs`` (and to Trent Mick and Jeff Rouse in particular) for -creating an incredibly useful simple module, as evidenced by the wide -number of users it has attracted over the years. - -Nonetheless, given the number of long-standing open issues -and pull requests, and no clear path towards `ensuring -that maintenance of the package would continue or grow -<https://github.com/ActiveState/appdirs/issues/79>`_, this fork was -created. - -Contributions are most welcome. - -
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/src/platformdirs.egg-info/SOURCES.txt
Deleted
@@ -1,39 +0,0 @@ -.gitignore -.pre-commit-config.yaml -.readthedocs.yml -CHANGES.rst -LICENSE.txt -README.rst -codecov.yml -pyproject.toml -setup.cfg -setup.py -tox.ini -whitelist.txt -.github/CODEOWNERS -.github/workflows/check.yml -docs/api.rst -docs/changelog.rst -docs/conf.py -docs/index.rst -src/platformdirs/__init__.py -src/platformdirs/__main__.py -src/platformdirs/android.py -src/platformdirs/api.py -src/platformdirs/macos.py -src/platformdirs/py.typed -src/platformdirs/unix.py -src/platformdirs/version.py -src/platformdirs/windows.py -src/platformdirs.egg-info/PKG-INFO -src/platformdirs.egg-info/SOURCES.txt -src/platformdirs.egg-info/dependency_links.txt -src/platformdirs.egg-info/requires.txt -src/platformdirs.egg-info/top_level.txt -src/platformdirs.egg-info/zip-safe -tests/conftest.py -tests/test_android.py -tests/test_api.py -tests/test_comp_with_appdirs.py -tests/test_main.py -tests/test_unix.py \ No newline at end of file
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/src/platformdirs.egg-info/dependency_links.txt
Deleted
@@ -1,1 +0,0 @@ -
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/src/platformdirs.egg-info/requires.txt
Deleted
@@ -1,12 +0,0 @@ - -docs -Sphinx>=4 -furo>=2021.7.5b38 -proselint>=0.10.2 -sphinx-autodoc-typehints>=1.12 - -test -appdirs==1.4.4 -pytest>=6 -pytest-cov>=2.7 -pytest-mock>=3.6
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/src/platformdirs.egg-info/top_level.txt
Deleted
@@ -1,1 +0,0 @@ -platformdirs
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/src/platformdirs.egg-info/zip-safe
Deleted
@@ -1,1 +0,0 @@ -
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/tests
Deleted
-(directory)
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/tox.ini
Deleted
@@ -1,115 +0,0 @@ -tox -envlist = - fix - py310 - py39 - py38 - py37 - pypy3 - type - coverage - readme -isolated_build = true -skip_missing_interpreters = true -minversion = 3.21 - -testenv -description = run the unit tests with pytest under {basepython} -passenv = - ANDROID_DATA - ANDROID_ROOT -setenv = - COVERAGE_FILE = {toxworkdir}/.coverage.{envname} - COVERAGE_PROCESS_START = {toxinidir}/setup.cfg - _COVERAGE_SRC = {envsitepackagesdir}/platformdirs -extras = - test -commands = - pytest {tty:--color=yes} {posargs: \ - --junitxml {toxworkdir}{/}junit.{envname}.xml --cov {envsitepackagesdir}{/}platformdirs \ - --cov {toxinidir}{/}tests \ - --cov-config=setup.cfg --no-cov-on-fail --cov-report term-missing:skip-covered --cov-context=test \ - --cov-report html:{envtmpdir}{/}htmlcov --cov-report xml:{toxworkdir}{/}coverage.{envname}.xml \ - tests} -package = wheel -wheel_build_env = .pkg - -testenv:fix -description = run static analysis and style check using flake8 -passenv = - HOMEPATH - PROGRAMDATA -skip_install = true -deps = - pre-commit>=2 -commands = - pre-commit run --all-files --show-diff-on-failure - -testenv:type -description = run type check on code base -setenv = - {tty:MYPY_FORCE_COLOR = 1} -deps = - mypy==0.931 -commands = - mypy --strict src - mypy --strict tests - -testenv:coverage -description = combine coverage files and generate diff (against DIFF_AGAINST defaulting to origin/main) -passenv = - DIFF_AGAINST -setenv = - COVERAGE_FILE = {toxworkdir}/.coverage -skip_install = true -deps = - covdefaults>=2.1 - coverage>=6.2 - diff-cover>=6.4 -extras = -parallel_show_output = true -commands = - coverage combine - coverage report --skip-covered --show-missing - coverage xml -o {toxworkdir}/coverage.xml - coverage html -d {toxworkdir}/htmlcov - diff-cover --compare-branch {env:DIFF_AGAINST:origin/main} {toxworkdir}/coverage.xml -depends = - py310 - py39 - py38 - py37 - pypy3 - -testenv:readme -description = check that the long description is valid -passenv = - * -skip_install = true -deps = - build>=0.5 - twine>=3.2 -changedir = {toxinidir} -commands = - python -m build -o {envtmpdir} . - twine check {envtmpdir}/* - -testenv:dev -description = generate a DEV environment -usedevelop = true -extras = - test -commands = - python -m pip list --format=columns - python -c 'import sys; print(sys.executable)' - -testenv:docs -extras = - docs -commands = - python -c 'import glob; import subprocess; subprocess.call("proselint" + glob.glob("docs/*.rst"))' - sphinx-build -d "{envtmpdir}/doctree" docs "{toxworkdir}/docs_out" --color -b html {posargs} - python -c 'import pathlib; print("documentation available under \{0\}".format((pathlib.Path(r"{toxworkdir}") / "docs_out" / "index.html").as_uri()))' - -pytest -junit_family = xunit2
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/whitelist.txt
Deleted
@@ -1,39 +0,0 @@ -appauthor -appdirs -appname -autoclass -autodoc -buf -buf2 -const -csidl -delenv -dirs -func -getmembers -getuid -highbit -hkey -intersphinx -isfunction -jnius -kernel32 -lru -macos -multipath -normpath -ord -param -params -pathlib -pathsep -platformdirs -pyjnius -runtime -setenv -shell32 -typehints -unittest -usefixtures -winreg -xdg
View file
_service:tar_scm:platformdirs-3.5.0.tar.gz/LICENSE
Added
@@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2010-202x The platformdirs developers + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/PKG-INFO -> _service:tar_scm:platformdirs-3.5.0.tar.gz/PKG-INFO
Changed
@@ -1,16 +1,15 @@ Metadata-Version: 2.1 Name: platformdirs -Version: 2.5.1 -Summary: A small Python module for determining appropriate platform-specific dirs, e.g. a "user data dir". -Home-page: https://github.com/platformdirs/platformdirs -Maintainer: Bernát Gábor, Julian Berman, Ofek Lev, Ronny Pfannschmidt -Maintainer-email: gaborjbernat@gmail.com, Julian@GrayVines.com, oss@ofek.dev, opensource@ronnypfannschmidt.de -License: MIT +Version: 3.5.0 +Summary: A small Python package for determining appropriate platform-specific dirs, e.g. a "user data dir". +Project-URL: Documentation, https://platformdirs.readthedocs.io +Project-URL: Homepage, https://github.com/platformdirs/platformdirs Project-URL: Source, https://github.com/platformdirs/platformdirs Project-URL: Tracker, https://github.com/platformdirs/platformdirs/issues -Project-URL: Documentation, https://platformdirs.readthedocs.io/ -Keywords: application directory log cache user -Platform: UNKNOWN +Maintainer-email: Bernát Gábor <gaborjbernat@gmail.com>, Julian Berman <Julian@GrayVines.com>, Ofek Lev <oss@ofek.dev>, Ronny Pfannschmidt <opensource@ronnypfannschmidt.de> +License-Expression: MIT +License-File: LICENSE +Keywords: appdirs,application,cache,directory,log,user Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License @@ -22,14 +21,24 @@ Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 +Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Software Development :: Libraries :: Python Modules Requires-Python: >=3.7 -Description-Content-Type: text/x-rst +Requires-Dist: typing-extensions>=4.5; python_version < '3.8' Provides-Extra: docs +Requires-Dist: furo>=2023.3.27; extra == 'docs' +Requires-Dist: proselint>=0.13; extra == 'docs' +Requires-Dist: sphinx-autodoc-typehints!=1.23.4,>=1.23; extra == 'docs' +Requires-Dist: sphinx>=6.1.3; extra == 'docs' Provides-Extra: test -License-File: LICENSE.txt +Requires-Dist: appdirs==1.4.4; extra == 'test' +Requires-Dist: covdefaults>=2.3; extra == 'test' +Requires-Dist: pytest-cov>=4; extra == 'test' +Requires-Dist: pytest-mock>=3.10; extra == 'test' +Requires-Dist: pytest>=7.3.1; extra == 'test' +Description-Content-Type: text/x-rst The problem =========== @@ -64,7 +73,7 @@ ``platformdirs`` to the rescue ============================== -This kind of thing is what the ``platformdirs`` module is for. +This kind of thing is what the ``platformdirs`` package is for. ``platformdirs`` will help you choose an appropriate: - user data dir (``user_data_dir``) @@ -78,7 +87,6 @@ And also: -- Is a single module so other Python packages can vendor their own private copy. - Is slightly opinionated on the directory names used. Look for "OPINION" in documentation and code for when an opinion is being applied. @@ -160,17 +168,24 @@ >>> appname = "SuperApp" >>> appauthor = "Acme" >>> user_data_dir(appname, appauthor) - '/data/data/com.termux/files/SuperApp' + '/data/data/com.myApp/files/SuperApp' >>> user_cache_dir(appname, appauthor) - '/data/data/com.termux/cache/SuperApp' + '/data/data/com.myApp/cache/SuperApp' >>> user_log_dir(appname, appauthor) - '/data/data/com.termux/cache/SuperApp/log' + '/data/data/com.myApp/cache/SuperApp/log' >>> user_config_dir(appname) - '/data/data/com.termux/shared_prefs/SuperApp' + '/data/data/com.myApp/shared_prefs/SuperApp' >>> user_documents_dir() '/storage/emulated/0/Documents' >>> user_runtime_dir(appname, appauthor) - '/data/data/com.termux/cache/SuperApp/tmp' + '/data/data/com.myApp/cache/SuperApp/tmp' + +Note: Some android apps like Termux and Pydroid are used as shells. These +apps are used by the end user to emulate Linux environment. Presence of +``SHELL`` environment variable is used by Platformdirs to differentiate +between general android apps and android apps used as shells. Shell android +apps also support ``XDG_*`` environment variables. + ``PlatformDirs`` for convenience ================================ @@ -237,5 +252,3 @@ created. Contributions are most welcome. - -
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/README.rst -> _service:tar_scm:platformdirs-3.5.0.tar.gz/README.rst
Changed
@@ -31,7 +31,7 @@ ``platformdirs`` to the rescue ============================== -This kind of thing is what the ``platformdirs`` module is for. +This kind of thing is what the ``platformdirs`` package is for. ``platformdirs`` will help you choose an appropriate: - user data dir (``user_data_dir``) @@ -45,7 +45,6 @@ And also: -- Is a single module so other Python packages can vendor their own private copy. - Is slightly opinionated on the directory names used. Look for "OPINION" in documentation and code for when an opinion is being applied. @@ -127,17 +126,24 @@ >>> appname = "SuperApp" >>> appauthor = "Acme" >>> user_data_dir(appname, appauthor) - '/data/data/com.termux/files/SuperApp' + '/data/data/com.myApp/files/SuperApp' >>> user_cache_dir(appname, appauthor) - '/data/data/com.termux/cache/SuperApp' + '/data/data/com.myApp/cache/SuperApp' >>> user_log_dir(appname, appauthor) - '/data/data/com.termux/cache/SuperApp/log' + '/data/data/com.myApp/cache/SuperApp/log' >>> user_config_dir(appname) - '/data/data/com.termux/shared_prefs/SuperApp' + '/data/data/com.myApp/shared_prefs/SuperApp' >>> user_documents_dir() '/storage/emulated/0/Documents' >>> user_runtime_dir(appname, appauthor) - '/data/data/com.termux/cache/SuperApp/tmp' + '/data/data/com.myApp/cache/SuperApp/tmp' + +Note: Some android apps like Termux and Pydroid are used as shells. These +apps are used by the end user to emulate Linux environment. Presence of +``SHELL`` environment variable is used by Platformdirs to differentiate +between general android apps and android apps used as shells. Shell android +apps also support ``XDG_*`` environment variables. + ``PlatformDirs`` for convenience ================================
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/pyproject.toml -> _service:tar_scm:platformdirs-3.5.0.tar.gz/pyproject.toml
Changed
@@ -1,6 +1,75 @@ build-system -requires = "setuptools >= 44", "wheel >= 0.30", "setuptools_scmtoml>=5" -build-backend = "setuptools.build_meta" +build-backend = "hatchling.build" +requires = + "hatch-vcs>=0.3", + "hatchling>=1.14", + + +project +name = "platformdirs" +description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." +readme = "README.rst" +keywords = + "appdirs", + "application", + "cache", + "directory", + "log", + "user", + +license = "MIT" +maintainers = + { name = "Bernát Gábor", email = "gaborjbernat@gmail.com" }, + { name = "Julian Berman", email = "Julian@GrayVines.com" }, + { name = "Ofek Lev", email = "oss@ofek.dev" }, + { name = "Ronny Pfannschmidt", email = "opensource@ronnypfannschmidt.de" }, + +requires-python = ">=3.7" +classifiers = + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Software Development :: Libraries :: Python Modules", + +dynamic = + "version", + +dependencies = + 'typing-extensions>=4.5; python_version < "3.8"', + +optional-dependencies.docs = + "furo>=2023.3.27", + "proselint>=0.13", + "sphinx>=6.1.3", + "sphinx-autodoc-typehints!=1.23.4,>=1.23", + +optional-dependencies.test = + "appdirs==1.4.4", + "covdefaults>=2.3", + "pytest>=7.3.1", + "pytest-cov>=4", + "pytest-mock>=3.10", + +urls.Documentation = "https://platformdirs.readthedocs.io" +urls.Homepage = "https://github.com/platformdirs/platformdirs" +urls.Source = "https://github.com/platformdirs/platformdirs" +urls.Tracker = "https://github.com/platformdirs/platformdirs/issues" + +tool.hatch +build.hooks.vcs.version-file = "src/platformdirs/version.py" +build.targets.sdist.include = "/src", "/tests" +version.source = "vcs" tool.black line-length = 120 @@ -9,11 +78,27 @@ profile = "black" known_first_party = "platformdirs" -tool.setuptools_scm -write_to = "src/platformdirs/version.py" -write_to_template = """ -\"\"\" Version information \"\"\" +tool.flake8 +max-complexity = 22 +max-line-length = 120 +unused-arguments-ignore-abstract-functions = true +noqa-require-code = true +dictionaries = "en_US", "python", "technical", "django" + +tool.coverage +html.show_contexts = true +html.skip_covered = false +run.relative_files = true +paths.source = "src", "**/site-packages" +report.fail_under = 76 +run.parallel = true +run.plugins = "covdefaults" + +tool.mypy +python_version = "3.11" +show_error_codes = true +strict = true +overrides = { module = "appdirs.*", "jnius.*", ignore_missing_imports = true } -__version__ = "{version}" -__version_info__ = {version_tuple} -""" +tool.pep8 +max-line-length = "120"
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/src/platformdirs/__init__.py -> _service:tar_scm:platformdirs-3.5.0.tar.gz/src/platformdirs/__init__.py
Changed
@@ -7,13 +7,15 @@ import os import sys from pathlib import Path -from typing import TYPE_CHECKING -if TYPE_CHECKING: - from typing_extensions import Literal # pragma: no cover +if sys.version_info >= (3, 8): # pragma: no cover (py38+) + from typing import Literal +else: # pragma: no cover (py38+) + from typing_extensions import Literal from .api import PlatformDirsABC -from .version import __version__, __version_info__ +from .version import __version__ +from .version import __version_tuple__ as __version_info__ def _set_platform_dir_class() -> typePlatformDirsABC: @@ -25,6 +27,9 @@ from platformdirs.unix import Unix as Result if os.getenv("ANDROID_DATA") == "/data" and os.getenv("ANDROID_ROOT") == "/system": + if os.getenv("SHELL") or os.getenv("PREFIX"): + return Result + from platformdirs.android import _android_folder if _android_folder() is not None: @@ -44,15 +49,23 @@ appauthor: str | None | LiteralFalse = None, version: str | None = None, roaming: bool = False, + ensure_exists: bool = False, ) -> str: """ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. - :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.version>`. + :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`. + :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: data directory tied to the user """ - return PlatformDirs(appname=appname, appauthor=appauthor, version=version, roaming=roaming).user_data_dir + return PlatformDirs( + appname=appname, + appauthor=appauthor, + version=version, + roaming=roaming, + ensure_exists=ensure_exists, + ).user_data_dir def site_data_dir( @@ -60,15 +73,23 @@ appauthor: str | None | LiteralFalse = None, version: str | None = None, multipath: bool = False, + ensure_exists: bool = False, ) -> str: """ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param multipath: See `roaming <platformdirs.api.PlatformDirsABC.multipath>`. + :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: data directory shared by users """ - return PlatformDirs(appname=appname, appauthor=appauthor, version=version, multipath=multipath).site_data_dir + return PlatformDirs( + appname=appname, + appauthor=appauthor, + version=version, + multipath=multipath, + ensure_exists=ensure_exists, + ).site_data_dir def user_config_dir( @@ -76,15 +97,23 @@ appauthor: str | None | LiteralFalse = None, version: str | None = None, roaming: bool = False, + ensure_exists: bool = False, ) -> str: """ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. - :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.version>`. + :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`. + :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: config directory tied to the user """ - return PlatformDirs(appname=appname, appauthor=appauthor, version=version, roaming=roaming).user_config_dir + return PlatformDirs( + appname=appname, + appauthor=appauthor, + version=version, + roaming=roaming, + ensure_exists=ensure_exists, + ).user_config_dir def site_config_dir( @@ -92,15 +121,23 @@ appauthor: str | None | LiteralFalse = None, version: str | None = None, multipath: bool = False, + ensure_exists: bool = False, ) -> str: """ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param multipath: See `roaming <platformdirs.api.PlatformDirsABC.multipath>`. + :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: config directory shared by the users """ - return PlatformDirs(appname=appname, appauthor=appauthor, version=version, multipath=multipath).site_config_dir + return PlatformDirs( + appname=appname, + appauthor=appauthor, + version=version, + multipath=multipath, + ensure_exists=ensure_exists, + ).site_config_dir def user_cache_dir( @@ -108,15 +145,47 @@ appauthor: str | None | LiteralFalse = None, version: str | None = None, opinion: bool = True, + ensure_exists: bool = False, ) -> str: """ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param opinion: See `roaming <platformdirs.api.PlatformDirsABC.opinion>`. + :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: cache directory tied to the user """ - return PlatformDirs(appname=appname, appauthor=appauthor, version=version, opinion=opinion).user_cache_dir + return PlatformDirs( + appname=appname, + appauthor=appauthor, + version=version, + opinion=opinion, + ensure_exists=ensure_exists, + ).user_cache_dir + + +def site_cache_dir( + appname: str | None = None, + appauthor: str | None | LiteralFalse = None, + version: str | None = None, + opinion: bool = True, + ensure_exists: bool = False, +) -> str: + """ + :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. + :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. + :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. + :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. + :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. + :returns: cache directory tied to the user + """ + return PlatformDirs( + appname=appname, + appauthor=appauthor, + version=version, + opinion=opinion, + ensure_exists=ensure_exists, + ).site_cache_dir def user_state_dir( @@ -124,15 +193,23 @@ appauthor: str | None | LiteralFalse = None, version: str | None = None, roaming: bool = False, + ensure_exists: bool = False, ) -> str: """ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. - :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.version>`. + :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`. + :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: state directory tied to the user """ - return PlatformDirs(appname=appname, appauthor=appauthor, version=version, roaming=roaming).user_state_dir + return PlatformDirs( + appname=appname, + appauthor=appauthor, + version=version, + roaming=roaming, + ensure_exists=ensure_exists, + ).user_state_dir def user_log_dir( @@ -140,15 +217,23 @@ appauthor: str | None | LiteralFalse = None, version: str | None = None, opinion: bool = True, + ensure_exists: bool = False, ) -> str: """ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param opinion: See `roaming <platformdirs.api.PlatformDirsABC.opinion>`. + :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: log directory tied to the user """ - return PlatformDirs(appname=appname, appauthor=appauthor, version=version, opinion=opinion).user_log_dir + return PlatformDirs( + appname=appname, + appauthor=appauthor, + version=version, + opinion=opinion, + ensure_exists=ensure_exists, + ).user_log_dir def user_documents_dir() -> str: @@ -158,20 +243,49 @@ return PlatformDirs().user_documents_dir +def user_pictures_dir() -> str: + """ + :returns: pictures directory tied to the user + """ + return PlatformDirs().user_pictures_dir + + +def user_videos_dir() -> str: + """ + :returns: videos directory tied to the user + """ + return PlatformDirs().user_videos_dir + + +def user_music_dir() -> str: + """ + :returns: music directory tied to the user + """ + return PlatformDirs().user_music_dir + + def user_runtime_dir( appname: str | None = None, appauthor: str | None | LiteralFalse = None, version: str | None = None, opinion: bool = True, + ensure_exists: bool = False, ) -> str: """ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. + :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: runtime directory tied to the user """ - return PlatformDirs(appname=appname, appauthor=appauthor, version=version, opinion=opinion).user_runtime_dir + return PlatformDirs( + appname=appname, + appauthor=appauthor, + version=version, + opinion=opinion, + ensure_exists=ensure_exists, + ).user_runtime_dir def user_data_path( @@ -179,15 +293,23 @@ appauthor: str | None | LiteralFalse = None, version: str | None = None, roaming: bool = False, + ensure_exists: bool = False, ) -> Path: """ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. - :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.version>`. + :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`. + :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: data path tied to the user """ - return PlatformDirs(appname=appname, appauthor=appauthor, version=version, roaming=roaming).user_data_path + return PlatformDirs( + appname=appname, + appauthor=appauthor, + version=version, + roaming=roaming, + ensure_exists=ensure_exists, + ).user_data_path def site_data_path( @@ -195,15 +317,23 @@ appauthor: str | None | LiteralFalse = None, version: str | None = None, multipath: bool = False, + ensure_exists: bool = False, ) -> Path: """ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param multipath: See `multipath <platformdirs.api.PlatformDirsABC.multipath>`. + :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: data path shared by users """ - return PlatformDirs(appname=appname, appauthor=appauthor, version=version, multipath=multipath).site_data_path + return PlatformDirs( + appname=appname, + appauthor=appauthor, + version=version, + multipath=multipath, + ensure_exists=ensure_exists, + ).site_data_path def user_config_path( @@ -211,15 +341,23 @@ appauthor: str | None | LiteralFalse = None, version: str | None = None, roaming: bool = False, + ensure_exists: bool = False, ) -> Path: """ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. - :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.version>`. + :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`. + :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: config path tied to the user """ - return PlatformDirs(appname=appname, appauthor=appauthor, version=version, roaming=roaming).user_config_path + return PlatformDirs( + appname=appname, + appauthor=appauthor, + version=version, + roaming=roaming, + ensure_exists=ensure_exists, + ).user_config_path def site_config_path( @@ -227,15 +365,47 @@ appauthor: str | None | LiteralFalse = None, version: str | None = None, multipath: bool = False, + ensure_exists: bool = False, ) -> Path: """ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param multipath: See `roaming <platformdirs.api.PlatformDirsABC.multipath>`. + :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: config path shared by the users """ - return PlatformDirs(appname=appname, appauthor=appauthor, version=version, multipath=multipath).site_config_path + return PlatformDirs( + appname=appname, + appauthor=appauthor, + version=version, + multipath=multipath, + ensure_exists=ensure_exists, + ).site_config_path + + +def site_cache_path( + appname: str | None = None, + appauthor: str | None | LiteralFalse = None, + version: str | None = None, + opinion: bool = True, + ensure_exists: bool = False, +) -> Path: + """ + :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. + :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. + :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. + :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. + :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. + :returns: cache directory tied to the user + """ + return PlatformDirs( + appname=appname, + appauthor=appauthor, + version=version, + opinion=opinion, + ensure_exists=ensure_exists, + ).site_cache_path def user_cache_path( @@ -243,15 +413,23 @@ appauthor: str | None | LiteralFalse = None, version: str | None = None, opinion: bool = True, + ensure_exists: bool = False, ) -> Path: """ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param opinion: See `roaming <platformdirs.api.PlatformDirsABC.opinion>`. + :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: cache path tied to the user """ - return PlatformDirs(appname=appname, appauthor=appauthor, version=version, opinion=opinion).user_cache_path + return PlatformDirs( + appname=appname, + appauthor=appauthor, + version=version, + opinion=opinion, + ensure_exists=ensure_exists, + ).user_cache_path def user_state_path( @@ -259,15 +437,23 @@ appauthor: str | None | LiteralFalse = None, version: str | None = None, roaming: bool = False, + ensure_exists: bool = False, ) -> Path: """ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. - :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.version>`. + :param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`. + :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: state path tied to the user """ - return PlatformDirs(appname=appname, appauthor=appauthor, version=version, roaming=roaming).user_state_path + return PlatformDirs( + appname=appname, + appauthor=appauthor, + version=version, + roaming=roaming, + ensure_exists=ensure_exists, + ).user_state_path def user_log_path( @@ -275,15 +461,23 @@ appauthor: str | None | LiteralFalse = None, version: str | None = None, opinion: bool = True, + ensure_exists: bool = False, ) -> Path: """ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param opinion: See `roaming <platformdirs.api.PlatformDirsABC.opinion>`. + :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: log path tied to the user """ - return PlatformDirs(appname=appname, appauthor=appauthor, version=version, opinion=opinion).user_log_path + return PlatformDirs( + appname=appname, + appauthor=appauthor, + version=version, + opinion=opinion, + ensure_exists=ensure_exists, + ).user_log_path def user_documents_path() -> Path: @@ -293,20 +487,49 @@ return PlatformDirs().user_documents_path +def user_pictures_path() -> Path: + """ + :returns: pictures path tied to the user + """ + return PlatformDirs().user_pictures_path + + +def user_videos_path() -> Path: + """ + :returns: videos path tied to the user + """ + return PlatformDirs().user_videos_path + + +def user_music_path() -> Path: + """ + :returns: music path tied to the user + """ + return PlatformDirs().user_music_path + + def user_runtime_path( appname: str | None = None, appauthor: str | None | LiteralFalse = None, version: str | None = None, opinion: bool = True, + ensure_exists: bool = False, ) -> Path: """ :param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`. :param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`. :param version: See `version <platformdirs.api.PlatformDirsABC.version>`. :param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`. + :param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. :returns: runtime path tied to the user """ - return PlatformDirs(appname=appname, appauthor=appauthor, version=version, opinion=opinion).user_runtime_path + return PlatformDirs( + appname=appname, + appauthor=appauthor, + version=version, + opinion=opinion, + ensure_exists=ensure_exists, + ).user_runtime_path __all__ = @@ -321,16 +544,24 @@ "user_state_dir", "user_log_dir", "user_documents_dir", + "user_pictures_dir", + "user_videos_dir", + "user_music_dir", "user_runtime_dir", "site_data_dir", "site_config_dir", + "site_cache_dir", "user_data_path", "user_config_path", "user_cache_path", "user_state_path", "user_log_path", "user_documents_path", + "user_pictures_path", + "user_videos_path", + "user_music_path", "user_runtime_path", "site_data_path", "site_config_path", + "site_cache_path",
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/src/platformdirs/__main__.py -> _service:tar_scm:platformdirs-3.5.0.tar.gz/src/platformdirs/__main__.py
Changed
@@ -9,9 +9,13 @@ "user_state_dir", "user_log_dir", "user_documents_dir", + "user_pictures_dir", + "user_videos_dir", + "user_music_dir", "user_runtime_dir", "site_data_dir", "site_config_dir", + "site_cache_dir", )
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/src/platformdirs/android.py -> _service:tar_scm:platformdirs-3.5.0.tar.gz/src/platformdirs/android.py
Changed
@@ -12,8 +12,9 @@ class Android(PlatformDirsABC): """ Follows the guidance `from here <https://android.stackexchange.com/a/216132>`_. Makes use of the - `appname <platformdirs.api.PlatformDirsABC.appname>` and - `version <platformdirs.api.PlatformDirsABC.version>`. + `appname <platformdirs.api.PlatformDirsABC.appname>`, + `version <platformdirs.api.PlatformDirsABC.version>`, + `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. """ @property @@ -44,6 +45,11 @@ return self._append_app_name_and_version(cast(str, _android_folder()), "cache") @property + def site_cache_dir(self) -> str: + """:return: cache directory shared by users, same as `user_cache_dir`""" + return self.user_cache_dir + + @property def user_state_dir(self) -> str: """:return: state directory tied to the user, same as `user_data_dir`""" return self.user_data_dir @@ -67,6 +73,27 @@ return _android_documents_folder() @property + def user_pictures_dir(self) -> str: + """ + :return: pictures directory tied to the user e.g. ``/storage/emulated/0/Pictures`` + """ + return _android_pictures_folder() + + @property + def user_videos_dir(self) -> str: + """ + :return: videos directory tied to the user e.g. ``/storage/emulated/0/DCIM/Camera`` + """ + return _android_videos_folder() + + @property + def user_music_dir(self) -> str: + """ + :return: music directory tied to the user e.g. ``/storage/emulated/0/Music`` + """ + return _android_music_folder() + + @property def user_runtime_dir(self) -> str: """ :return: runtime directory tied to the user, same as `user_cache_dir` if not opinionated else ``tmp`` in it, @@ -115,6 +142,54 @@ return documents_dir +@lru_cache(maxsize=1) +def _android_pictures_folder() -> str: + """:return: pictures folder for the Android OS""" + # Get directories with pyjnius + try: + from jnius import autoclass + + Context = autoclass("android.content.Context") # noqa: N806 + Environment = autoclass("android.os.Environment") # noqa: N806 + pictures_dir: str = Context.getExternalFilesDir(Environment.DIRECTORY_PICTURES).getAbsolutePath() + except Exception: + pictures_dir = "/storage/emulated/0/Pictures" + + return pictures_dir + + +@lru_cache(maxsize=1) +def _android_videos_folder() -> str: + """:return: videos folder for the Android OS""" + # Get directories with pyjnius + try: + from jnius import autoclass + + Context = autoclass("android.content.Context") # noqa: N806 + Environment = autoclass("android.os.Environment") # noqa: N806 + videos_dir: str = Context.getExternalFilesDir(Environment.DIRECTORY_DCIM).getAbsolutePath() + except Exception: + videos_dir = "/storage/emulated/0/DCIM/Camera" + + return videos_dir + + +@lru_cache(maxsize=1) +def _android_music_folder() -> str: + """:return: music folder for the Android OS""" + # Get directories with pyjnius + try: + from jnius import autoclass + + Context = autoclass("android.content.Context") # noqa: N806 + Environment = autoclass("android.os.Environment") # noqa: N806 + music_dir: str = Context.getExternalFilesDir(Environment.DIRECTORY_MUSIC).getAbsolutePath() + except Exception: + music_dir = "/storage/emulated/0/Music" + + return music_dir + + __all__ = "Android",
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/src/platformdirs/api.py -> _service:tar_scm:platformdirs-3.5.0.tar.gz/src/platformdirs/api.py
Changed
@@ -22,6 +22,7 @@ roaming: bool = False, multipath: bool = False, opinion: bool = True, + ensure_exists: bool = False, ): """ Create a new platform directory. @@ -32,6 +33,7 @@ :param roaming: See `roaming`. :param multipath: See `multipath`. :param opinion: See `opinion`. + :param ensure_exists: See `ensure_exists`. """ self.appname = appname #: The name of application. self.appauthor = appauthor @@ -56,6 +58,11 @@ returned. By default, the first item would only be returned. """ self.opinion = opinion #: A flag to indicating to use opinionated values. + self.ensure_exists = ensure_exists + """ + Optionally create the directory (and any missing parents) upon access if it does not exist. + By default, no directories are created. + """ def _append_app_name_and_version(self, *base: str) -> str: params = list(base1:) @@ -63,7 +70,13 @@ params.append(self.appname) if self.version: params.append(self.version) - return os.path.join(base0, *params) + path = os.path.join(base0, *params) + self._optionally_create_directory(path) + return path + + def _optionally_create_directory(self, path: str) -> None: + if self.ensure_exists: + Path(path).mkdir(parents=True, exist_ok=True) @property @abstractmethod @@ -92,6 +105,11 @@ @property @abstractmethod + def site_cache_dir(self) -> str: + """:return: cache directory shared by users""" + + @property + @abstractmethod def user_state_dir(self) -> str: """:return: state directory tied to the user""" @@ -107,6 +125,21 @@ @property @abstractmethod + def user_pictures_dir(self) -> str: + """:return: pictures directory tied to the user""" + + @property + @abstractmethod + def user_videos_dir(self) -> str: + """:return: videos directory tied to the user""" + + @property + @abstractmethod + def user_music_dir(self) -> str: + """:return: music directory tied to the user""" + + @property + @abstractmethod def user_runtime_dir(self) -> str: """:return: runtime directory tied to the user""" @@ -136,6 +169,11 @@ return Path(self.user_cache_dir) @property + def site_cache_path(self) -> Path: + """:return: cache path shared by users""" + return Path(self.site_cache_dir) + + @property def user_state_path(self) -> Path: """:return: state path tied to the user""" return Path(self.user_state_dir) @@ -151,6 +189,21 @@ return Path(self.user_documents_dir) @property + def user_pictures_path(self) -> Path: + """:return: pictures path tied to the user""" + return Path(self.user_pictures_dir) + + @property + def user_videos_path(self) -> Path: + """:return: videos path tied to the user""" + return Path(self.user_videos_dir) + + @property + def user_music_path(self) -> Path: + """:return: music path tied to the user""" + return Path(self.user_music_dir) + + @property def user_runtime_path(self) -> Path: """:return: runtime path tied to the user""" return Path(self.user_runtime_dir)
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/src/platformdirs/macos.py -> _service:tar_scm:platformdirs-3.5.0.tar.gz/src/platformdirs/macos.py
Changed
@@ -9,14 +9,15 @@ """ Platform directories for the macOS operating system. Follows the guidance from `Apple documentation <https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html>`_. - Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>` and - `version <platformdirs.api.PlatformDirsABC.version>`. + Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>`, + `version <platformdirs.api.PlatformDirsABC.version>`, + `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. """ @property def user_data_dir(self) -> str: """:return: data directory tied to the user, e.g. ``~/Library/Application Support/$appname/$version``""" - return self._append_app_name_and_version(os.path.expanduser("~/Library/Application Support/")) + return self._append_app_name_and_version(os.path.expanduser("~/Library/Application Support")) @property def site_data_dir(self) -> str: @@ -25,13 +26,13 @@ @property def user_config_dir(self) -> str: - """:return: config directory tied to the user, e.g. ``~/Library/Preferences/$appname/$version``""" - return self._append_app_name_and_version(os.path.expanduser("~/Library/Preferences/")) + """:return: config directory tied to the user, same as `user_data_dir`""" + return self.user_data_dir @property def site_config_dir(self) -> str: - """:return: config directory shared by the users, e.g. ``/Library/Preferences/$appname``""" - return self._append_app_name_and_version("/Library/Preferences") + """:return: config directory shared by the users, same as `site_data_dir`""" + return self.site_data_dir @property def user_cache_dir(self) -> str: @@ -39,6 +40,11 @@ return self._append_app_name_and_version(os.path.expanduser("~/Library/Caches")) @property + def site_cache_dir(self) -> str: + """:return: cache directory shared by users, e.g. ``/Library/Caches/$appname/$version``""" + return self._append_app_name_and_version("/Library/Caches") + + @property def user_state_dir(self) -> str: """:return: state directory tied to the user, same as `user_data_dir`""" return self.user_data_dir @@ -54,6 +60,21 @@ return os.path.expanduser("~/Documents") @property + def user_pictures_dir(self) -> str: + """:return: pictures directory tied to the user, e.g. ``~/Pictures``""" + return os.path.expanduser("~/Pictures") + + @property + def user_videos_dir(self) -> str: + """:return: videos directory tied to the user, e.g. ``~/Movies``""" + return os.path.expanduser("~/Movies") + + @property + def user_music_dir(self) -> str: + """:return: music directory tied to the user, e.g. ``~/Music``""" + return os.path.expanduser("~/Music") + + @property def user_runtime_dir(self) -> str: """:return: runtime directory tied to the user, e.g. ``~/Library/Caches/TemporaryItems/$appname/$version``""" return self._append_app_name_and_version(os.path.expanduser("~/Library/Caches/TemporaryItems"))
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/src/platformdirs/unix.py -> _service:tar_scm:platformdirs-3.5.0.tar.gz/src/platformdirs/unix.py
Changed
@@ -24,7 +24,8 @@ `appname <platformdirs.api.PlatformDirsABC.appname>`, `version <platformdirs.api.PlatformDirsABC.version>`, `multipath <platformdirs.api.PlatformDirsABC.multipath>`, - `opinion <platformdirs.api.PlatformDirsABC.opinion>`. + `opinion <platformdirs.api.PlatformDirsABC.opinion>`, + `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. """ @property @@ -94,6 +95,13 @@ return self._append_app_name_and_version(path) @property + def site_cache_dir(self) -> str: + """ + :return: cache directory shared by users, e.g. ``/var/tmp/$appname/$version`` + """ + return self._append_app_name_and_version("/var/tmp") + + @property def user_state_dir(self) -> str: """ :return: state directory tied to the user, e.g. ``~/.local/state/$appname/$version`` or @@ -107,9 +115,9 @@ @property def user_log_dir(self) -> str: """ - :return: log directory tied to the user, same as `user_data_dir` if not opinionated else ``log`` in it + :return: log directory tied to the user, same as `user_state_dir` if not opinionated else ``log`` in it """ - path = self.user_cache_dir + path = self.user_state_dir if self.opinion: path = os.path.join(path, "log") return path @@ -119,13 +127,28 @@ """ :return: documents directory tied to the user, e.g. ``~/Documents`` """ - documents_dir = _get_user_dirs_folder("XDG_DOCUMENTS_DIR") - if documents_dir is None: - documents_dir = os.environ.get("XDG_DOCUMENTS_DIR", "").strip() - if not documents_dir: - documents_dir = os.path.expanduser("~/Documents") + return _get_user_media_dir("XDG_DOCUMENTS_DIR", "~/Documents") + + @property + def user_pictures_dir(self) -> str: + """ + :return: pictures directory tied to the user, e.g. ``~/Pictures`` + """ + return _get_user_media_dir("XDG_PICTURES_DIR", "~/Pictures") + + @property + def user_videos_dir(self) -> str: + """ + :return: videos directory tied to the user, e.g. ``~/Videos`` + """ + return _get_user_media_dir("XDG_VIDEOS_DIR", "~/Videos") - return documents_dir + @property + def user_music_dir(self) -> str: + """ + :return: music directory tied to the user, e.g. ``~/Music`` + """ + return _get_user_media_dir("XDG_MUSIC_DIR", "~/Music") @property def user_runtime_dir(self) -> str: @@ -148,6 +171,11 @@ """:return: config path shared by the users. Only return first item, even if ``multipath`` is set to ``True``""" return self._first_item_as_path_if_multipath(self.site_config_dir) + @property + def site_cache_path(self) -> Path: + """:return: cache path shared by users. Only return first item, even if ``multipath`` is set to ``True``""" + return self._first_item_as_path_if_multipath(self.site_cache_dir) + def _first_item_as_path_if_multipath(self, directory: str) -> Path: if self.multipath: # If multipath is True, the first path is returned. @@ -155,6 +183,16 @@ return Path(directory) +def _get_user_media_dir(env_var: str, fallback_tilde_path: str) -> str: + media_dir = _get_user_dirs_folder(env_var) + if media_dir is None: + media_dir = os.environ.get(env_var, "").strip() + if not media_dir: + media_dir = os.path.expanduser(fallback_tilde_path) + + return media_dir + + def _get_user_dirs_folder(key: str) -> str | None: """Return directory from user-dirs.dirs config file. See https://freedesktop.org/wiki/Software/xdg-user-dirs/""" user_dirs_config_path = os.path.join(Unix().user_config_dir, "user-dirs.dirs")
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/src/platformdirs/version.py -> _service:tar_scm:platformdirs-3.5.0.tar.gz/src/platformdirs/version.py
Changed
@@ -1,4 +1,4 @@ -""" Version information """ - -__version__ = "2.5.1" -__version_info__ = (2, 5, 1) +# file generated by setuptools_scm +# don't change, don't track in version control +__version__ = version = '3.5.0' +__version_tuple__ = version_tuple = (3, 5, 0)
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/src/platformdirs/windows.py -> _service:tar_scm:platformdirs-3.5.0.tar.gz/src/platformdirs/windows.py
Changed
@@ -2,6 +2,7 @@ import ctypes import os +import sys from functools import lru_cache from typing import Callable @@ -16,7 +17,9 @@ `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`, `version <platformdirs.api.PlatformDirsABC.version>`, `roaming <platformdirs.api.PlatformDirsABC.roaming>`, - `opinion <platformdirs.api.PlatformDirsABC.opinion>`.""" + `opinion <platformdirs.api.PlatformDirsABC.opinion>`, + `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`. + """ @property def user_data_dir(self) -> str: @@ -40,7 +43,9 @@ params.append(opinion_value) if self.version: params.append(self.version) - return os.path.join(path, *params) + path = os.path.join(path, *params) + self._optionally_create_directory(path) + return path @property def site_data_dir(self) -> str: @@ -68,6 +73,12 @@ return self._append_parts(path, opinion_value="Cache") @property + def site_cache_dir(self) -> str: + """:return: cache directory shared by users, e.g. ``C:\\ProgramData\\$appauthor\\$appname\\Cache\\$version``""" + path = os.path.normpath(get_win_folder("CSIDL_COMMON_APPDATA")) + return self._append_parts(path, opinion_value="Cache") + + @property def user_state_dir(self) -> str: """:return: state directory tied to the user, same as `user_data_dir`""" return self.user_data_dir @@ -80,6 +91,7 @@ path = self.user_data_dir if self.opinion: path = os.path.join(path, "Logs") + self._optionally_create_directory(path) return path @property @@ -90,6 +102,27 @@ return os.path.normpath(get_win_folder("CSIDL_PERSONAL")) @property + def user_pictures_dir(self) -> str: + """ + :return: pictures directory tied to the user e.g. ``%USERPROFILE%\\Pictures`` + """ + return os.path.normpath(get_win_folder("CSIDL_MYPICTURES")) + + @property + def user_videos_dir(self) -> str: + """ + :return: videos directory tied to the user e.g. ``%USERPROFILE%\\Videos`` + """ + return os.path.normpath(get_win_folder("CSIDL_MYVIDEO")) + + @property + def user_music_dir(self) -> str: + """ + :return: music directory tied to the user e.g. ``%USERPROFILE%\\Music`` + """ + return os.path.normpath(get_win_folder("CSIDL_MYMUSIC")) + + @property def user_runtime_dir(self) -> str: """ :return: runtime directory tied to the user, e.g. @@ -101,8 +134,9 @@ def get_win_folder_from_env_vars(csidl_name: str) -> str: """Get folder from environment variables.""" - if csidl_name == "CSIDL_PERSONAL": # does not have an environment name - return os.path.join(os.path.normpath(os.environ"USERPROFILE"), "Documents") + result = get_win_folder_if_csidl_name_not_env_var(csidl_name) + if result is not None: + return result env_var_name = { "CSIDL_APPDATA": "APPDATA", @@ -117,6 +151,22 @@ return result +def get_win_folder_if_csidl_name_not_env_var(csidl_name: str) -> str | None: + """Get folder for a CSIDL name that does not exist as an environment variable.""" + if csidl_name == "CSIDL_PERSONAL": + return os.path.join(os.path.normpath(os.environ"USERPROFILE"), "Documents") + + if csidl_name == "CSIDL_MYPICTURES": + return os.path.join(os.path.normpath(os.environ"USERPROFILE"), "Pictures") + + if csidl_name == "CSIDL_MYVIDEO": + return os.path.join(os.path.normpath(os.environ"USERPROFILE"), "Videos") + + if csidl_name == "CSIDL_MYMUSIC": + return os.path.join(os.path.normpath(os.environ"USERPROFILE"), "Music") + return None + + def get_win_folder_from_registry(csidl_name: str) -> str: """Get folder from the registry. @@ -129,10 +179,14 @@ "CSIDL_COMMON_APPDATA": "Common AppData", "CSIDL_LOCAL_APPDATA": "Local AppData", "CSIDL_PERSONAL": "Personal", + "CSIDL_MYPICTURES": "My Pictures", + "CSIDL_MYVIDEO": "My Video", + "CSIDL_MYMUSIC": "My Music", }.get(csidl_name) if shell_folder_name is None: raise ValueError(f"Unknown CSIDL name: {csidl_name}") - + if sys.platform != "win32": # only needed for mypy type checker to know that this code runs only on Windows + raise NotImplementedError import winreg key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders") @@ -147,6 +201,9 @@ "CSIDL_COMMON_APPDATA": 35, "CSIDL_LOCAL_APPDATA": 28, "CSIDL_PERSONAL": 5, + "CSIDL_MYPICTURES": 39, + "CSIDL_MYVIDEO": 14, + "CSIDL_MYMUSIC": 13, }.get(csidl_name) if csidl_const is None: raise ValueError(f"Unknown CSIDL name: {csidl_name}")
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/tests/conftest.py -> _service:tar_scm:platformdirs-3.5.0.tar.gz/tests/conftest.py
Changed
@@ -12,9 +12,13 @@ "user_state_dir", "user_log_dir", "user_documents_dir", + "user_pictures_dir", + "user_videos_dir", + "user_music_dir", "user_runtime_dir", "site_data_dir", "site_config_dir", + "site_cache_dir", )
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/tests/test_android.py -> _service:tar_scm:platformdirs-3.5.0.tar.gz/tests/test_android.py
Changed
@@ -48,9 +48,13 @@ "user_config_dir": f"/data/data/com.example/shared_prefs{suffix}", "site_config_dir": f"/data/data/com.example/shared_prefs{suffix}", "user_cache_dir": f"/data/data/com.example/cache{suffix}", + "site_cache_dir": f"/data/data/com.example/cache{suffix}", "user_state_dir": f"/data/data/com.example/files{suffix}", "user_log_dir": f"/data/data/com.example/cache{suffix}{'' if params.get('opinion', True) is False else '/log'}", "user_documents_dir": "/storage/emulated/0/Documents", + "user_pictures_dir": "/storage/emulated/0/Pictures", + "user_videos_dir": "/storage/emulated/0/DCIM/Camera", + "user_music_dir": "/storage/emulated/0/Music", "user_runtime_dir": f"/data/data/com.example/cache{suffix}{'' if not params.get('opinion', True) else '/tmp'}", } expected = expected_mapfunc
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/tests/test_api.py -> _service:tar_scm:platformdirs-3.5.0.tar.gz/tests/test_api.py
Changed
@@ -53,8 +53,17 @@ @pytest.mark.parametrize("root", "A", "/system", None) @pytest.mark.parametrize("data", "D", "/data", None) @pytest.mark.parametrize("path", "/data/data/a/files", "/C") -def test_android_active(monkeypatch: MonkeyPatch, root: str | None, data: str | None, path: str) -> None: - for env_var, value in {"ANDROID_DATA": data, "ANDROID_ROOT": root}.items(): +@pytest.mark.parametrize("shell", "/data/data/com.app/files/usr/bin/sh", "/usr/bin/sh", None) +@pytest.mark.parametrize("prefix", "/data/data/com.termux/files/usr", None) +def test_android_active( + monkeypatch: MonkeyPatch, + root: str | None, + data: str | None, + path: str, + shell: str | None, + prefix: str | None, +) -> None: + for env_var, value in {"ANDROID_DATA": data, "ANDROID_ROOT": root, "SHELL": shell, "PREFIX": prefix}.items(): if value is None: monkeypatch.delenv(env_var, raising=False) else: @@ -65,7 +74,9 @@ _android_folder.cache_clear() monkeypatch.setattr(sys, "path", "/A", "/B", path) - expected = root == "/system" and data == "/data" and _android_folder() is not None + expected = ( + root == "/system" and data == "/data" and shell is None and prefix is None and _android_folder() is not None + ) if expected: assert platformdirs._set_platform_dir_class() is Android else:
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/tests/test_comp_with_appdirs.py -> _service:tar_scm:platformdirs-3.5.0.tar.gz/tests/test_comp_with_appdirs.py
Changed
@@ -57,13 +57,17 @@ if sys.platform == "darwin": msg = { # pragma: no cover "user_log_dir": "without appname produces NoneType error", - "site_config_dir": "ignores the version argument", - "user_config_dir": "uses Library/Preferences instead Application Support", } if func in msg: # pragma: no cover pytest.skip(f"`appdirs.{func}` {msgfunc} on macOS") # pragma: no cover + if sys.platform == "linux": + msg = { # pragma: no cover + "user_log_dir": "Uses XDG_STATE_DIR instead of appdirs.user_data_dir per the XDG spec", + } + if func in msg: # pragma: no cover + pytest.skip(f"`appdirs.{func}` {msgfunc} on Linux") # pragma: no cover new = getattr(platformdirs, func)(*params) old = getattr(appdirs, func)(*params) - assert new == old + assert new == old.rstrip("/")
View file
_service:tar_scm:platformdirs-3.5.0.tar.gz/tests/test_macos.py
Added
@@ -0,0 +1,43 @@ +from __future__ import annotations + +import os +from typing import Any + +import pytest + +from platformdirs.macos import MacOS + + +@pytest.mark.parametrize( + "params", + + pytest.param({}, id="no_args"), + pytest.param({"appname": "foo"}, id="app_name"), + pytest.param({"appname": "foo", "version": "v1.0"}, id="app_name_version"), + , +) +def test_macos(params: dictstr, Any, func: str) -> None: + result = getattr(MacOS(**params), func) + + home = os.path.expanduser("~") + suffix_elements = tuple(paramsi for i in ("appname", "version") if i in params) + suffix = os.sep.join(("",) + suffix_elements) if suffix_elements else "" + + expected_map = { + "user_data_dir": f"{home}/Library/Application Support{suffix}", + "site_data_dir": f"/Library/Application Support{suffix}", + "user_config_dir": f"{home}/Library/Application Support{suffix}", + "site_config_dir": f"/Library/Application Support{suffix}", + "user_cache_dir": f"{home}/Library/Caches{suffix}", + "site_cache_dir": f"/Library/Caches{suffix}", + "user_state_dir": f"{home}/Library/Application Support{suffix}", + "user_log_dir": f"{home}/Library/Logs{suffix}", + "user_documents_dir": f"{home}/Documents", + "user_pictures_dir": f"{home}/Pictures", + "user_videos_dir": f"{home}/Movies", + "user_music_dir": f"{home}/Music", + "user_runtime_dir": f"{home}/Library/Caches/TemporaryItems{suffix}", + } + expected = expected_mapfunc + + assert result == expected
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/tests/test_main.py -> _service:tar_scm:platformdirs-3.5.0.tar.gz/tests/test_main.py
Changed
@@ -12,7 +12,7 @@ def test_run_as_module() -> None: - out = check_output(sys.executable, "-m", "platformdirs", universal_newlines=True) + out = check_output(sys.executable, "-m", "platformdirs", text=True) assert out.startswith(f"-- platformdirs {__version__} --") for prop in PROPS:
View file
_service:tar_scm:platformdirs-2.5.1.tar.gz/tests/test_unix.py -> _service:tar_scm:platformdirs-3.5.0.tar.gz/tests/test_unix.py
Changed
@@ -4,6 +4,7 @@ import os import sys import typing +from pathlib import Path import pytest from _pytest.monkeypatch import MonkeyPatch @@ -12,38 +13,57 @@ from platformdirs.unix import Unix -def test_user_documents_dir(mocker: MockerFixture) -> None: - example_path = "/home/example/ExampleDocumentsFolder" +@pytest.mark.parametrize("prop", "user_documents_dir", "user_pictures_dir", "user_videos_dir", "user_music_dir") +def test_user_media_dir(mocker: MockerFixture, prop: str) -> None: + example_path = "/home/example/ExampleMediaFolder" mock = mocker.patch("platformdirs.unix._get_user_dirs_folder") mock.return_value = example_path - assert Unix().user_documents_dir == example_path - - -def test_user_documents_dir_env_var(mocker: MockerFixture) -> None: - # Mock documents dir not being in user-dirs.dirs file + assert getattr(Unix(), prop) == example_path + + +@pytest.mark.parametrize( + ("env_var", "prop"), + + pytest.param("XDG_DOCUMENTS_DIR", "user_documents_dir", id="user_documents_dir"), + pytest.param("XDG_PICTURES_DIR", "user_pictures_dir", id="user_pictures_dir"), + pytest.param("XDG_VIDEOS_DIR", "user_videos_dir", id="user_videos_dir"), + pytest.param("XDG_MUSIC_DIR", "user_music_dir", id="user_music_dir"), + , +) +def test_user_media_dir_env_var(mocker: MockerFixture, env_var: str, prop: str) -> None: + # Mock media dir not being in user-dirs.dirs file mock = mocker.patch("platformdirs.unix._get_user_dirs_folder") mock.return_value = None - example_path = "/home/example/ExampleDocumentsFolder" - mocker.patch.dict(os.environ, {"XDG_DOCUMENTS_DIR": example_path}) + example_path = "/home/example/ExampleMediaFolder" + mocker.patch.dict(os.environ, {env_var: example_path}) - assert Unix().user_documents_dir == example_path + assert getattr(Unix(), prop) == example_path -def test_user_documents_dir_default(mocker: MockerFixture) -> None: - # Mock documents dir not being in user-dirs.dirs file +@pytest.mark.parametrize( + ("env_var", "prop", "default_abs_path"), + + pytest.param("XDG_DOCUMENTS_DIR", "user_documents_dir", "/home/example/Documents", id="user_documents_dir"), + pytest.param("XDG_PICTURES_DIR", "user_pictures_dir", "/home/example/Pictures", id="user_pictures_dir"), + pytest.param("XDG_VIDEOS_DIR", "user_videos_dir", "/home/example/Videos", id="user_videos_dir"), + pytest.param("XDG_MUSIC_DIR", "user_music_dir", "/home/example/Music", id="user_music_dir"), + , +) +def test_user_media_dir_default(mocker: MockerFixture, env_var: str, prop: str, default_abs_path: str) -> None: + # Mock media dir not being in user-dirs.dirs file mock = mocker.patch("platformdirs.unix._get_user_dirs_folder") mock.return_value = None - # Mock no XDG_DOCUMENTS_DIR env variable being set - mocker.patch.dict(os.environ, {"XDG_DOCUMENTS_DIR": ""}) + # Mock no XDG env variable being set + mocker.patch.dict(os.environ, {env_var: ""}) # Mock home directory mocker.patch.dict(os.environ, {"HOME": "/home/example"}) # Mock home directory for running the test on Windows mocker.patch.dict(os.environ, {"USERPROFILE": "/home/example"}) - assert Unix().user_documents_dir == "/home/example/Documents" + assert getattr(Unix(), prop) == default_abs_path class XDGVariable(typing.NamedTuple): @@ -59,7 +79,7 @@ "site_config_dir": XDGVariable("XDG_CONFIG_DIRS", "/etc/xdg"), "user_cache_dir": XDGVariable("XDG_CACHE_HOME", "~/.cache"), "user_state_dir": XDGVariable("XDG_STATE_HOME", "~/.local/state"), - "user_log_dir": XDGVariable("XDG_CACHE_HOME", "~/.cache"), + "user_log_dir": XDGVariable("XDG_STATE_HOME", "~/.local/state"), "user_runtime_dir": XDGVariable("XDG_RUNTIME_DIR", "/run/user/1234"), } return mapping.get(func) @@ -120,3 +140,15 @@ unix.Unix().user_runtime_dir finally: importlib.reload(unix) + + +def test_ensure_exists_creates_folder(mocker: MockerFixture, tmp_path: Path) -> None: + mocker.patch.dict(os.environ, {"XDG_DATA_HOME": str(tmp_path)}) + data_path = Unix(appname="acme", ensure_exists=True).user_data_path + assert data_path.exists() + + +def test_folder_not_created_without_ensure_exists(mocker: MockerFixture, tmp_path: Path) -> None: + mocker.patch.dict(os.environ, {"XDG_DATA_HOME": str(tmp_path)}) + data_path = Unix(appname="acme", ensure_exists=False).user_data_path + assert not data_path.exists()
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2