Skip to main content

Load configuration files and access them with dot-style syntax

Project description

Thumos Configr

A simple Python3 class to facilitate easy loading and access to configuration settings using dot-style syntax, with support for Yaml, JSON, TOML and XML. To clarify, dot-style syntax refers to something such as the following:

Example YAML file:

configuration:
  mysql:
    host: localhost
    port: 3600

Using Configr, the values could be accessed in this way:

from configr import Configr
cr = Configr("config.yaml")
cr["configuration.mysql.host"]
>> localhost
cr["configuration.mysql.port"]
>> 3600

You may ask why one would want to use this instead of simply using a dictionary. The answer is; why not? Perhaps it's more convenient, more appealing to the eyes, or perhaps you're even coming from something like Spring Boot where this is the way it's usually done.

However, other characters than the dot can be used as a separator.

cr = Configr("config.yaml", separator="/")
cr["configuration/mysql/host"]
>> localhost

It is also possible to set an initial root key, to minimize verbosity when using deep configuration files that may contain settings not pertinent to the script or application you are working on. Take the following example YAML file:

this:
  is:
    nothingInteresting: Jimmy With A Law Degree Is Like A Chimp With A Machine Gun.
    really:
      fantastically:
        deep: Is it not?
      absolutely:
        annoying: Indeed
cr = Configr("config.yaml", root_key="this.is.really")
cr["fantastically.deep"]
>> Is it not?
cr["absolutely.annoying"]
>> Indeed

Installation

pip install thumos-configr

Import like this:

from configr import Configr

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

thumos-configr-0.0.5.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

thumos_configr-0.0.5-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file thumos-configr-0.0.5.tar.gz.

File metadata

  • Download URL: thumos-configr-0.0.5.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for thumos-configr-0.0.5.tar.gz
Algorithm Hash digest
SHA256 c6cb1fb3e53f76aa7f9cd5d8ec4f077ec2917e820b4b3e537c2f8e6096fb23ef
MD5 5094ee4b13fb8688b4ce97eb0783a5b0
BLAKE2b-256 c15ef8b4f03a2889a70f025849a49a5002439aad595c997d259a9d4835782af1

See more details on using hashes here.

File details

Details for the file thumos_configr-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: thumos_configr-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for thumos_configr-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 67ca3d9fc5c7c51eb0ca6412ff141cd2c720666c60b74ea813bc373b15d0c63b
MD5 c47c4556ae74f2409fd4fba725654de3
BLAKE2b-256 7f3020371ddc3899cfd9ba23093bcbd313f53d193794e30607a10f2c63fb89cd

See more details on using hashes here.

Supported by

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