Define family trees in YAML http://pypi.org/project/yamily

Fabian Peter Hammerle 170187d87f release v0.2.0 преди 4 години
.githooks 2f3c4c9d46 GPLv3+ преди 4 години
tests 9b749b0f98 cli yamily-dot: added --comment arg преди 4 години
yamily 9b749b0f98 cli yamily-dot: added --comment arg преди 4 години
.gitignore 1b4229a633 gitignore преди 4 години
.pylintrc 762a858e4b added class docstrings преди 4 години
CHANGELOG.md 170187d87f release v0.2.0 преди 4 години
COPYING 2f3c4c9d46 GPLv3+ преди 4 години
Pipfile 203b3dfad3 simple yamily.graph.digraph prototype преди 4 години
Pipfile.lock 203b3dfad3 simple yamily.graph.digraph prototype преди 4 години
README.md 56ea025359 added Person.death_date преди 4 години
conftest.py 2f3c4c9d46 GPLv3+ преди 4 години
pytest.ini 203b3dfad3 simple yamily.graph.digraph prototype преди 4 години
setup.py 2f3c4c9d46 GPLv3+ преди 4 години

README.md

yamily

Define family trees in YAML

Setup

Debian / Ubuntu

$ sudo apt-get install python3-yaml python3-graphviz
$ pip3 install --user --upgrade yamily

Mac

$ brew install graphviz
$ pip3 install --upgrade yamily[yaml,graphviz]

Windows

  1. Download and install Graphviz.
  2. Download and install Python.
  3. Open Command Prompt / cmd.exe.
  4. Run command pip install --user --upgrade yamily[yaml,graphviz].

Usage

Import YAML

>>> import yaml, yamily, yamily.yaml
>>> alice_yaml = '''
... !person
... identifier: alice
... name: Alice Test
... birth_date: 1919-12-23
... mother: !person
...   identifier: alice-mother
...   name: Carol Test
...   birth_date: 1892-10-26
...   death_date: 1983-11-02
... father: !person
...   identifier: bob
...   name: Bob Test
... '''
>>> alice = yaml.load(alice_yaml, Loader=yamily.yaml.Loader)
>>> alice
Person(alice, Alice Test, *1919-12-23)
>>> alice.mother
Person(alice-mother, Carol Test, *1892-10-26, †1983-11-02)

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/