[cineoob] handle death date
This commit is contained in:
parent
4f37c01feb
commit
c7bc1ecbb9
3 changed files with 20 additions and 5 deletions
|
|
@ -75,6 +75,7 @@ class PersonPage(BasePage):
|
|||
biography = NotAvailable
|
||||
birth_place = NotAvailable
|
||||
birth_date = NotAvailable
|
||||
death_date = NotAvailable
|
||||
real_name = NotAvailable
|
||||
gender = NotAvailable
|
||||
nationality = NotAvailable
|
||||
|
|
@ -103,10 +104,20 @@ class PersonPage(BasePage):
|
|||
time.append('1')
|
||||
time.append('1')
|
||||
birth_date = datetime(int(time[0]),int(time[1]),int(time[2]))
|
||||
dtimes = self.parser.select(td_overview,'time[itemprop=deathDate]')
|
||||
if len(dtimes) > 0:
|
||||
dtime = dtimes[0].attrib.get('datetime','').split('-')
|
||||
if len(dtime) == 2:
|
||||
dtime.append('1')
|
||||
elif len(dtime) == 1:
|
||||
dtime.append('1')
|
||||
dtime.append('1')
|
||||
death_date = datetime(int(dtime[0]),int(dtime[1]),int(dtime[2]))
|
||||
|
||||
person = Person(id,name)
|
||||
person.real_name = real_name
|
||||
person.birth_date = birth_date
|
||||
person.death_date = death_date
|
||||
person.birth_place = birth_place
|
||||
person.gender = gender
|
||||
person.nationality = nationality
|
||||
|
|
|
|||
|
|
@ -104,14 +104,17 @@ class PersonInfoFormatter(IFormatter):
|
|||
result = u'%s%s%s\n' % (self.BOLD, obj.name, self.NC)
|
||||
result += 'ID: %s\n' % obj.fullid
|
||||
result += 'Real name: %s\n' % obj.real_name
|
||||
result += 'Birth place: %s\n' % obj.birth_place
|
||||
if obj.birth_date != NotAvailable:
|
||||
result += 'Birth date: %s\n' % obj.birth_date.strftime('%Y-%m-%d')
|
||||
age = num_years(obj.birth_date)
|
||||
if obj.death_date != NotAvailable:
|
||||
age = num_years(obj.birth_date,obj.death_date)
|
||||
result += 'Death date: %s at %s years old\n' % (obj.death_date.strftime('%Y-%m-%d'),age)
|
||||
else:
|
||||
age = num_years(obj.birth_date)
|
||||
result += 'Age: %s\n' % age
|
||||
else:
|
||||
result += 'Birth date: %s\n' % obj.birth_date
|
||||
age = NotAvailable
|
||||
result += 'Age: %s\n' % age
|
||||
result += 'Birth place: %s\n' % obj.birth_place
|
||||
result += 'Gender: %s\n' % obj.gender
|
||||
result += 'Nationality: %s\n' % obj.nationality
|
||||
if obj.roles:
|
||||
|
|
@ -132,7 +135,7 @@ class PersonListFormatter(PrettyFormatter):
|
|||
return obj.name
|
||||
|
||||
def get_description(self, obj):
|
||||
if obj.birth_date != NotAvailable:
|
||||
if obj.birth_date != NotAvailable and obj.death_date == NotAvailable:
|
||||
age = num_years(obj.birth_date)
|
||||
else:
|
||||
age = NotAvailable
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ class Person(CapBaseObject):
|
|||
name = StringField('Star name of a person')
|
||||
real_name = StringField('Real name of a person')
|
||||
birth_date = DateField('Birth date of a person')
|
||||
death_date = DateField('Death date of a person')
|
||||
birth_place = StringField('City and country of birth of a person')
|
||||
gender = StringField('Gender of a person')
|
||||
nationality = StringField('Nationality of a person')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue