Utilities
The follow functions exist to provide additional high-level functionality.
auto()
Given an arbitrary file, this library can attempt to map its structure into a Python object synchronized back to that file. For example, a YAML file named sample.yml
containing the following:
names:
- Alice
- Bob
numbers:
- 1
- 2
can be loaded into an object:
>>> from datafiles import auto
>>> sample = auto('sample.yml')
>>> sample.names
['Alice', 'Bob']
where modified attributes:
>>> sample.numbers.append(3)
are automatically reflected in the file:
1 2 3 4 5 6 7 8 9 |
|
Additional examples can be found in this Jupyter Notebook.