Skip to main content

Simple cascading/nested scope/namespace manager

Project description

https://img.shields.io/pypi/v/delegatum.svg https://img.shields.io/travis/datagazing/delegatum.svg Documentation Status

Simple cascading/nested scope/namespace manager

Delegatum walks a list of objects that can represent key/value mappings and returns the first match found for a key.

  • Supports dictionaries, argparse, configparser, mapping functions

  • Most dictionary-like objects should work as well

  • Python json and yaml parsers return dictionaries, and so are supported

Examples

The following example searches, in order: command line arguments, a config file, a json string, a yaml string, and the output of a function.

import delegatum
import json
import yaml # Requires external package PyYAML
j = json.loads('{"verbose": true, "output": "file.txt"}')
y = yaml.safe_load(some_yaml_string)
some_f = lambda x: x * x
delegatus = delegatum.Delegatum([cmdline, configfile, j, y, some_f])
print(delegatus['verbose'])
print(delegatus['garbage'])

Attributes

defaultobject

Default value to return if no lookup succeeds

Raises

DelegatumError

General library error; should only occur if misconfigured

DelegatumMissError

Used internally for flow control

See Also

Standard library:

  • argparse

  • configparser

  • json

  • tomllib

External modules:

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

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

delegatum-1.0.0.tar.gz (11.1 kB view hashes)

Uploaded Source

Built Distribution

delegatum-1.0.0-py3-none-any.whl (3.1 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