Skip to main content

Manage configuration files from multiple source in python

Project description

catilo

Manage configuration files from multiple source in python. Create a variable directory for your configuration sources.

Directories contain sources and each source has a priority. The lower the priority value, higher is the priority. When you retrieve a variables, it looks into all the sources and retrieve the one with the highest priority. For eg, you have added two source -

  • source1 : json config file - contain default values - priority = 10
  • source2 : url - contains overrides - priority = 5

It will look into source 2 first, if not found will search in source1 , if then not found will raise "UndefinedVariableException"

Quickstart

Use pip install catilo to install Catilo

Import the module at the start and define a variable directory.

from catilo.catilo import VariableDirectory
my_directory = VariableDirectory()

For simple dictionaries:

my_directory.add_source("fruitdetails",priority=5,dictionary={
    "fruit": "Apple",
    "size": "Large",
    "color": "Red"
})
value = my_directory.get("fruit") ## returns "Apple"

For yaml/json based files

my_directory.add_file_source("configfile",priority=6,file="path/to/config.yaml")
my_directory.get("variable")

For URL's

my_directory.add_url_source("sampleurl",3,"https://raw.githubusercontent.com/jptalukdar/catilo/master/tests/tests_data/json/sample1.json")
value = my_directory.get("fruit") ## returns "Apple"

For Environment variables

my_directory.enable_environment_vars(prefix="CATILO_")
value = my_directory.get("CATILO_my_variable")

## If you don't want to strip the prefix during get, use `strip_prefix=True`
my_directory.enable_environment_vars(prefix="CATILO_",strip_prefix=True)
value = my_directory.get("my_variable")

Features

  1. Allows you to store multiple configuration files with priority value.
  2. Support for the following sources
    1. python dictionaries
    2. yaml files
    3. json files
    4. url (get method, json format)
    5. Environment variables
  3. Ability to add custom sources
  4. Stores config in flat_dictionary (can be overriden) for '.' notation access
  5. Ability to add variables in runtime
    1. Add as default variable
    2. Add as normal variable
  6. Output multiple sources into a single json or yaml file

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

catilo-0.2.6.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

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

catilo-0.2.6-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file catilo-0.2.6.tar.gz.

File metadata

  • Download URL: catilo-0.2.6.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

File hashes

Hashes for catilo-0.2.6.tar.gz
Algorithm Hash digest
SHA256 a14581371c866c4230677d73b33076019f8686e19071bd1ceb522b1887540768
MD5 42b3aa5fa0696dfa43801692ad9d7f80
BLAKE2b-256 f6a39ab5c5c01d60789d7c4702f25254da222f6c184b8bbd510420f9550a4fc8

See more details on using hashes here.

File details

Details for the file catilo-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: catilo-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 18.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

File hashes

Hashes for catilo-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 0d3103cfc4431f922ff9fecfb1e584ff0bf91b72196f1c8e3fe8a995de10e1fe
MD5 bb9465df1fd011e45dc03bb674dad65a
BLAKE2b-256 4604c356baeaed75678a66ae6ebffaafe455b81243a0f1aeb6b6c16fba2e4ab7

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