Skip to main content

Deals with configuration files in yaml

Project description

confyaml

Python package to deal with configuration files in YAML

Usage

from confyaml import Config

# Assumes you have a file called config.yaml
config = Config()
# But you can also pass the path of other yaml file
other_config = Config("other_config.yaml")

# Parameters can be accessed in three different ways:
print(config.a)
print(config["a"])
print(config.get("a"))
# If the parameter does not exist, AttributeError will be raised

# Parameters can be set in three different ways:
config.a = "b"
config.set("a", "c")
config["a"] = "e"

# You can save your changes to the yaml file
# If you pass an extra argument, it will save the yaml file on that path
config.save("new_config.yaml")

Tests

Unittests available on the "test" folder. You can run them using this:

 python -m unittest tests.test1.GetSetSaveTest
 python -m unittest tests.test1.SanityTest

References

This Stack Overflow answer helped me to figure out how to transform the YAML file into a object accessible with dot (.) operator

This blog post helped me on merging the yaml file with the Config object

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

confyaml-0.1.5.tar.gz (3.3 kB view details)

Uploaded Source

File details

Details for the file confyaml-0.1.5.tar.gz.

File metadata

  • Download URL: confyaml-0.1.5.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for confyaml-0.1.5.tar.gz
Algorithm Hash digest
SHA256 01bfb530abfaa24c1c4b494c813bf6cb7b7a7a04cd87c55654892c0cc4a055c0
MD5 0ef6553ee5ad8102407b70e9c8c14066
BLAKE2b-256 5bde0d7f717eff4e3ea79d9a488a3e275461582b37fcacf44b205764e0800ee6

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