https://github.com/bruxisma/dirs
Python library for getting dirs for platform specific use cases (such as XDG, or Roaming AppData)
https://github.com/bruxisma/dirs
appdirs pypi python xdg
Last synced: 7 months ago
JSON representation
Python library for getting dirs for platform specific use cases (such as XDG, or Roaming AppData)
- Host: GitHub
- URL: https://github.com/bruxisma/dirs
- Owner: bruxisma
- License: mit
- Created: 2019-09-13T05:01:43.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-19T17:57:47.000Z (almost 6 years ago)
- Last Synced: 2025-01-15T23:54:55.023Z (9 months ago)
- Topics: appdirs, pypi, python, xdg
- Language: Python
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Overview
---
![PyPI - Python Version][versions]
![PyPI - License][license]
![PyPI - Package][package]
![Code style: black][style]`dirs` is a small python library in the spirit of appdirs[1] and other XDG
focused directory libraries. However, there are several that I've
identified with these other libraries:1. Overengineered solutions to get a few simple paths
2. When Windows support is available, it reads from the registry, rather than
using the recommended approach of using `KnownFolderID`.
3. No memoization of results. This can be costly when repeatedly working with
filesystem paths
4. None of these libraries return a `pathlib.Path` object
5. None of these libraries use the `typing` module for better static analysis
tooling
6. None of these libraries use `dataclasses` or `attrs` to prevent overwriting
internals or "changing" state on the fly.`dirs` tries to solve all of this by using `ctypes` under Windows for initial
calls, `functools.lru_cache` for an alternative API, lazy generation of
`config_dirs` and `data_dirs` on all platforms, and many others. Proper
documentation will be uploaded at some point, but the code is fairly readable
and easy to understand.## Example Use
```py
from dirs import User, Site # Using `*` is also permittedapp = User('app-name')
print(app.config) # prints a joined path with User.config_home() and 'app-name'
print(User.config_home()) # This returns the Path as-is
for path in Site.config_dirs(): # This is a generator, so it's iterable
print(f'{path} exists: {path.exists()}')
```[versions]: https://img.shields.io/pypi/pyversions/dirs?style=for-the-badge
[license]: https://img.shields.io/pypi/l/dirs?style=for-the-badge
[package]: https://img.shields.io/pypi/v/dirs?style=for-the-badge
[style]: https://img.shields.io/badge/code%20style-black-000000.svg[1]: https://github.com/ActiveState/appdirs