Define family trees in YAML
Project description
yamily
Define family trees in YAML
Setup
$ sudo apt-get install python3-yaml python3-graphviz # optional on debian / ubuntu
$ pip3 install --user --upgrade yamily[yaml,graphviz]
Usage
Import YAML
>>> 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)
Multiple YAML Files
>>> alice_yaml = '''
... !person
... identifier: alice
... name: Alice Test
... birth_date: 2019-12-23
... mother: carol
... '''
>>> carol_yaml = '''
... !person
... identifier: carol
... name: Carol Test
... birth_date: 1992-10-26
... '''
>>> collection = yamily.PersonCollection()
>>> for person_yaml in [alice_yaml, carol_yaml]:
... person = yaml.load(person_yaml, Loader=yamily.yaml.Loader)
... collection.add_person(person)
Person(alice, Alice Test, *2019-12-23)
Person(carol, Carol Test, *1992-10-26)
>>> collection['alice'].mother
Person(carol, Carol Test, *1992-10-26)
>>> collection['carol'] is collection['alice'].mother
True
Export YAML
>>> import datetime, yaml, yamily, yamily.yaml
>>> alice = yamily.Person("alice")
>>> alice.name = "Alice Test"
>>> alice.birth_date = datetime.date(2019, 12, 23)
>>> alice
Person(alice, Alice Test, *2019-12-23)
>>> alice.father = yamily.Person("alice-father")
>>> alice.father.name = "Bob Test"
>>> print(yaml.dump(alice, Dumper=yamily.yaml.Dumper))
!person
birth_date: 2019-12-23
father: !person
identifier: alice-father
name: Bob Test
identifier: alice
name: Alice Test
<BLANKLINE>
Plot Family Tree
$ yamily-dot . > tree.dot
$ dot -Tpdf -O tree.dot
Develop
$ git clone git@git.hammerle.me:fphammerle/yamily.git
$ cd yamily
$ git config --local core.hooksPath .githooks/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
yamily-0.1.0.tar.gz
(30.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
yamily-0.1.0-py3-none-any.whl
(21.2 kB
view details)
File details
Details for the file yamily-0.1.0.tar.gz.
File metadata
- Download URL: yamily-0.1.0.tar.gz
- Upload date:
- Size: 30.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c65eeca3561d4f38f3aa97a1269cc48b00a56b66f8ce1ea7bd464ba7339dead
|
|
| MD5 |
8d66ab3bae3002c13b4274c1bab5bd22
|
|
| BLAKE2b-256 |
eed4a0ac1125fcd088b020405dd1c7c5f57f884ea2f84cd7d48ae7d8125fb742
|
File details
Details for the file yamily-0.1.0-py3-none-any.whl.
File metadata
- Download URL: yamily-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd07182230d405bd6925464169a26da989951e92c2ff1e501241fdb3b29e9f8a
|
|
| MD5 |
0164739bd261f66f26381b3fbe78c1eb
|
|
| BLAKE2b-256 |
8fd3d19824230748c6d83250dc4080dd2a99e3eabe9434d3fcb0363b2607b7e4
|