Преглед на файлове

collection: add mother & father

Fabian Peter Hammerle преди 4 години
родител
ревизия
d8b2396083
променени са 1 файла, в които са добавени 8 реда и са изтрити 0 реда
  1. 8 0
      yamily/__init__.py

+ 8 - 0
yamily/__init__.py

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