Skip to main content

Load stacks of JSON or YAML data

Project description

CfgStack is a configfile system reader. System? Yeah. In reading and parsing one file, CfgStack can be directed to go read other files and to incorporate their contents into the growing dataset.

CfgStack ("somefile")

Attempts to load the named file, first as a JSON file with a “.json” extension, and then as a YAML file with either a “.yaml” or “.yml” file extension. The loaded object must be a dictionary. The “data” member of the resulting object is an addict Dict of the loaded dataset. So far so simple.

_include_:
  - file1
  - file2
_default_:
  zero: 0
  one: 1
foo:
  this: that
  zero: null
var: value
bar:
  _default_:
    inner: inside_bar
  inside:
    oh: boy
    yep: really
baz:
  _include_:
    - file3

A few things going on here:

  • “_include_” keys are assumed to list additional data files which will be loaded and their contents merged with the dictionary at the same level. If multiple files are listed, they will be applied in order from the top down.

  • “_default_” keys provide default key:value pairs for all dictionary values at the current level

Note that all includes are applied first, then all defaults. Higher level values override lower level values, across both includes and defaults (includes first) and both for contents and data-type.

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

cfgstack-0.1.post12.tar.gz (22.6 kB view details)

Uploaded Source

File details

Details for the file cfgstack-0.1.post12.tar.gz.

File metadata

  • Download URL: cfgstack-0.1.post12.tar.gz
  • Upload date:
  • Size: 22.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for cfgstack-0.1.post12.tar.gz
Algorithm Hash digest
SHA256 f4b60f421b75682c6167a145fe7d9a4d4b0e48a6dc846b134dfbb32a76ae770e
MD5 a5aa833059d88c0a1c643b1a90ff034e
BLAKE2b-256 0051e7c55047c81cc23ad46c25e54ebee637b49786ad36a9fe58005f2dae89bf

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