def add_parents(child, depth, max_depth): if depth+1 < max_depth: dad = Person(child.name + '_dad', Gender.MALE) mom = Person(child.name + '_mom', Gender.FEMALE) people.append(dad) people.append(mom) child.set_father(dad) child.set_mother(mom) add_parents(dad, depth+1, max_depth) add_parents(mom, depth+1, max_depth)
def setUp(self): # create a few Persons self.child = Person('kid', 'NA') self.mom = Person('mom', 'f') self.dad = Person('dad', 'm') # make a deep family history self.generations = 4 self.people = people = [] self.root_child = Person('root_child', Gender.UNKNOWN) people.append(self.root_child) def add_parents(child, depth, max_depth): if depth+1 < max_depth: dad = Person(child.name + '_dad', Gender.MALE) mom = Person(child.name + '_mom', Gender.FEMALE) people.append(dad) people.append(mom) child.set_father(dad) child.set_mother(mom) add_parents(dad, depth+1, max_depth) add_parents(mom, depth+1, max_depth) add_parents(self.root_child, 0, self.generations)