Skip to main content

Configure your application in a friendlier and more consistent way!

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

config-better-1.1.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

config_better-1.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file config-better-1.1.0.tar.gz.

File metadata

  • Download URL: config-better-1.1.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for config-better-1.1.0.tar.gz
Algorithm Hash digest
SHA256 cafb848b46d1740a42b2d279b0c8979c1b4b6e8a4a9d4f439bc059ac87f74d43
MD5 0051cd1bf3d952a6d6ece91e13fba9b4
BLAKE2b-256 a2b988f4eec983a2383055f897efaf90032eb81df54beb871518b65876fea2f7

See more details on using hashes here.

File details

Details for the file config_better-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: config_better-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for config_better-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 00ff28afd0026bff140829b3675d8fb284ff7b95f28e2d71e5031435e1e6c25b
MD5 a02366bbeea38c9d41177e1261c7d784
BLAKE2b-256 41c31e68f348116d00c22ff253656136151fd91e81e3fd0e9a575113c8a1357f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page