Browse Source

collection: add mother & father

Fabian Peter Hammerle 4 years ago
parent
commit
d8b2396083
1 changed files with 8 additions and 0 deletions
  1. 8 0
      yamily/__init__.py

+ 8 - 0
yamily/__init__.py

@@ -124,9 +124,17 @@ class PersonCollection:
 
         >>> bob = Person("bob")
         >>> bob.birth_date = datetime.date(2010, 2, 3)
+        >>> bob.mother = Person("bob-mum")
+        >>> bob.father = Person("bob-dad")
         >>> c.add_person(bob)
         Person(bob, *2010-02-03)
+        >>> list(c)
+        [Person(alice), Person(bob, *2010-02-03), Person(bob-mum), Person(bob-dad)]
         """
+        if person.mother is not None:
+            self.add_person(person.mother)
+        if person.father is not None:
+            self.add_person(person.father)
         if person.identifier not in self._persons:
             self._persons[person.identifier] = person
             return person