YamlWrapper is an abstraction over PyYAML library. Its purpuse is to made easier to interact with .yaml
files. This is made possible by create/update/remove operations with two main abstract data types: YamlDictionary
and YamlList
.
You can find the official documentation at this link
pip install PythonYamlWrapper
from yaml_wrapper import YamlWrapper
yaml_wrapper: YamlWrapper = YamlWrapper("tmp/file_path.yaml")
The core functionalities provided by YamlWrapper
work with YamlDictionary
and YamlList
.
- Dictionary
key_1: "value"
key_2:
sub_key_1: "sub_value"
sub_key_2: 1
Is rappresented by:
data = [
YamlDictionary("key", "value"),
YamlDictionary("sub_key", [
YamlDictionary("sub_key_1", "sub_value"),
YamlDictionary("sub_key_2", 1)
])
]
- Lists
- "first_value"
- "second_value"
- "third_value"
Is rappresented by:
data = [
YamlList(["first_value", "second_value", "third_value"])
]
- Dictionary with list
key:
- "first_value"
- "second_value"
- "third_value"
Is rappresented by:
data = [
YamlDictionary("key", YamlList(["first_value", "second_value", "third_value"]))
]