From e34be2e06f88032824beaec5173419c60602591f Mon Sep 17 00:00:00 2001 From: gilad_ilsar Date: Thu, 22 Sep 2016 11:51:49 +0300 Subject: tester and person entity --- entities/person.py | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'entities') diff --git a/entities/person.py b/entities/person.py index b9e9d78..d541bb4 100644 --- a/entities/person.py +++ b/entities/person.py @@ -2,7 +2,7 @@ from entities.basic_entity import BasicEntity class Person(BasicEntity): - def __init__(self, name, date_of_birth, name_in_langs): + def __init__(self, name, date_of_birth, name_in_langs, bio_data): """ :param name: @@ -14,5 +14,35 @@ class Person(BasicEntity): } """ self.name = name - self.date_of_birth = date_of_birth + 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)) -- cgit v1.2.3