Browse Source

readme: added yaml import sample

Fabian Peter Hammerle 4 years ago
parent
commit
c3f82712af
1 changed files with 25 additions and 0 deletions
  1. 25 0
      README.md

+ 25 - 0
README.md

@@ -11,6 +11,31 @@ $ pip3 install --user --upgrade yamily
 
 ## Usage
 
+### Import YAML
+
+```python
+>>> import yaml, yamily, yamily.yaml
+>>> alice_yaml = '''
+... !person
+... identifier: alice
+... name: Alice Test
+... birth_date: 2019-12-23
+... mother: !person
+...   identifier: alice-mother
+...   name: Carol Test 
+...   birth_date: 1992-10-26
+... father: !person
+...   identifier: bob
+...   name: Bob Test
+... '''
+>>> alice = yaml.load(alice_yaml, Loader=yamily.yaml.Loader)
+>>> alice
+Person(alice, Alice Test, *2019-12-23)
+>>> alice.mother
+Person(alice-mother, Carol Test, *1992-10-26)
+
+```
+
 ### Export YAML
 
 ```python