Skip to main content

Load YAML configuration respecting XDG

Project description

configize

Python library to find and fetch YAML configuration for a program, respecting the XDG base directory specification.

Example

from configize import configize


# This will use $XDG_CONFIG_HOME
# The following files will be searched for, and the first existing file will be used:
# (Note, NAME is populated from the class kwarg 'Name')
# - $XDG_CONFIG_HOME/NAME.yaml
# - $XDG_CONFIG_HOME/NAME.yml
# - $XDG_CONFIG_HOME/NAME/NAME.yaml
# - $XDG_CONFIG_HOME/NAME/NAME.yml
# - $XDG_CONFIG_HOME/NAME/config.yaml
# - $XDG_CONFIG_HOME/NAME/config.yml
c = configize(Name="myproject")

# Alternatively, if using a custom path instead of XDG:
c = configize(Name="myproject", Path="/etc/myproject")

# the path field contains a pathlib.Path object to the config file
print(c.path)

# the config field contains a deserialized dict from the YAML file contents
print(c.config)

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

Configize-1.0.1.tar.gz (26.0 kB view hashes)

Uploaded Source

Built Distribution

Configize-1.0.1-py3-none-any.whl (26.4 kB view hashes)

Uploaded Python 3

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