HiYaPyCo is a Python library (current version 0.7.0) that facilitates hierarchical overlay and merging of configuration files written in YAML. It supports multiple merge methods, including deep merge, and features variable interpolation using Jinja2. The library is actively maintained with regular releases. [1, 2, 3]
pip install hiyapycoVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates loading and merging two YAML documents provided as strings. It uses `hiyapyco.METHOD_MERGE` for a deep merge and enables Jinja2 interpolation to resolve variables like `{{ first }}`. The resulting merged configuration is then pretty-printed. [1, 3]
Upgrade to Python 3 or pin hiyapyco version to <0.5.0.
Ensure all interpolated variables are defined, or set `hiyapyco.jinja2env = Environment(undefined=DebugUndefined)` before loading to make undefined variables appear as empty strings without errors. [1]
Pass `mergelists=True` or `method=hiyapyco.METHOD_MERGE` to the `hiyapyco.load()` function to enable list merging behavior. Example: `hiyapyco.load('file1.yaml', 'file2.yaml', method=hiyapyco.METHOD_MERGE, mergelists=True)`.Specify `none_behavior=hiyapyco.NONE_BEHAVIOR_OVERRIDE` (None overrides other values) or `none_behavior=hiyapyco.NONE_BEHAVIOR_IGNORE` (None is ignored) when calling `hiyapyco.load()`. [3]
Ensure PyYAML is installed by running `pip install PyYAML` or simply reinstalling `hiyapyco` to allow pip to resolve dependencies: `pip install hiyapyco`.
Provide a value for the missing variable or configure `hiyapyco`'s Jinja2 environment to handle undefined variables gracefully, e.g., by setting `hiyapyco.jinja2env = Environment(undefined=DebugUndefined)` before loading YAML. [1]
To achieve list merging (concatenation for simple lists, deep merge for lists of dicts), use `method=hiyapyco.METHOD_MERGE` and/or `mergelists=True` in your `hiyapyco.load` call. For example: `hiyapyco.load('file1.yaml', 'file2.yaml', method=hiyapyco.METHOD_MERGE, mergelists=True)`.