Skip to content
/ dirs Public

Python library for getting dirs for platform specific use cases (such as XDG, or Roaming AppData)

License

Notifications You must be signed in to change notification settings

bruxisma/dirs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview


PyPI - Python Version PyPI - License PyPI - Package Code style: black

dirs is a small python library in the spirit of appdirs1 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

from dirs import User, Site # Using `*` is also permitted

app = 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()}')

About

Python library for getting dirs for platform specific use cases (such as XDG, or Roaming AppData)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages