Skip to main content

config-better

PyPI CircleCI Build Status Codecov

Make use of directories for configuration / data / caching better and more user-friendly!

This module provides support for the XDG Base Directory specification, and OS-friendly fallbacks for Windows, Mac OS, and Linux if not otherwise specified.

Usage

import os.path

import configbetter

c = configbetter.Config('appname')

with open(os.path.join(c.config, 'config.json')) as conf:
    # ...

Available parameters for creating a Config instance:

  • force_unix allows you to force using Unix-like paths on Windows/Darwin if desired. This isn't really recommended on Windows but on Darwin it seems as though programs without a GUI usually use Unix-like configuration paths while GUI apps use the "standard" Darwin paths. By default this is False.

Available properties of Config:

  • .cache, which points to $XDG_CACHE_HOME if available, otherwise uses a generic system equivalent.
  • .config, which points to $XDG_CONFIG_HOME if available, otherwise uses a generic system equivalent.
  • .data, which points to $XDG_DATA_HOME if available, otherwise uses a generic system equivalent.

Additionally, the following methods are provided:

  • .makedirs() will create the cache, config and data directories if they do not already exist, including all parent directories.
  • .rmdirs() will remove any program-specific directories that would have been created by config-better.

Installation

pip install config-better

Developing

  1. Clone the repo
  2. git checkout -b some-feature-or-bugfix
  3. Do work
  4. Test with pytest (add tests to maintain coverage as best as possible)
  5. Run yapf -ir . and isort -rc . to standardize.
  6. Make a PR.

Release files for config-better 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for config-better 1.1.0
File Size Uploaded
config-better-1.1.0.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for config-better 1.1.0
File Interpreter ABI Platform
config_better-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.0 kB

Release files / config-better-1.1.0.tar.gz

Download URL config-better-1.1.0.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
cafb848b46d1740a42b2d279b0c8979c1b4b6e8a4a9d4f439bc059ac87f74d43
BLAKE2b-256 checksum
How to use checksums
a2b988f4eec983a2383055f897efaf90032eb81df54beb871518b65876fea2f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release files / config_better-1.1.0-py3-none-any.whl

Download URL config_better-1.1.0-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
00ff28afd0026bff140829b3675d8fb284ff7b95f28e2d71e5031435e1e6c25b
BLAKE2b-256 checksum
How to use checksums
41c31e68f348116d00c22ff253656136151fd91e81e3fd0e9a575113c8a1357f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page