README.md 1.3 KB

yamily

Define family trees in YAML

Setup

$ sudo apt-get install python3-yaml # optional on debian
$ pip3 install --user --upgrade yamily

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)

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>

Develop

$ git clone git@git.hammerle.me:fphammerle/yamily.git
$ cd yamily
$ git config --local core.hooksPath .githooks/