from entities.basic_entity import BasicEntity class Person(BasicEntity): def __init__(self, name, date_of_birth, name_in_langs, bio_data): """ :param name: :param date_of_birth: :param name_in_langs: Mapping of the persons's name in various languages, as a dictionary. For example: { "latin": "George" "heb": "[george in hebrew]" } """ self.name = name years_parts = date_of_birth.split('-') if (len(years_parts) == 2): self.birth_year = years_parts[0] self.death_year = years_parts[1] else: self.birth_year = date_of_birth.strip() self.death_year = '' self.name_in_langs = name_in_langs place_of_birth = list() place_of_death = list() profession = list() for comment in bio_data: encoded_comment = ''.join(comment).strip() if encoded_comment.startswith(u"מקום לידה: "): place_of_birth.append(encoded_comment.partition(u"מקום לידה: ")[2]) if encoded_comment.startswith(u"מקום פטירה: "): place_of_death.append(encoded_comment.partition(u"מקום פטירה: ")[2]) if encoded_comment.startswith(u"מקצוע: "): profession.append(encoded_comment.partition(u"מקום פטירה: ")[2]) self.place_of_birth = place_of_birth self.place_of_death = place_of_death self.profession = profession def print_entity(self): print("Name = " + self.name) print("Birth year = " + self.birth_year) print("Death year = " + self.death_year) print("Names in langs" + str(self.name_in_langs)) print("Places of birth = " + str(self.place_of_birth)) print("Places of death = " + str(self.place_of_death)) print("profession = " + str(self.profession))