[cineoob] do not display unavailable info

This commit is contained in:
Julien Veyssier 2013-03-06 15:16:53 +01:00
commit 2d0d76a6ad

View file

@ -39,13 +39,9 @@ class MovieInfoFormatter(IFormatter):
result += 'ID: %s\n' % obj.fullid result += 'ID: %s\n' % obj.fullid
if obj.release_date != NotAvailable: if obj.release_date != NotAvailable:
result += 'Released: %s\n' % obj.release_date.strftime('%Y-%m-%d') result += 'Released: %s\n' % obj.release_date.strftime('%Y-%m-%d')
else:
result += 'Released: %s\n' % obj.release_date
result += 'Country: %s\n' % obj.country result += 'Country: %s\n' % obj.country
if obj.duration != NotAvailable: if obj.duration != NotAvailable:
result += 'Duration: %smin\n' % obj.duration result += 'Duration: %smin\n' % obj.duration
else:
result += 'Duration: %s\n' % obj.duration
result += 'Note: %s\n' % obj.note result += 'Note: %s\n' % obj.note
if obj.roles: if obj.roles:
result += '\n%sRelated persons%s\n' % (self.BOLD, self.NC) result += '\n%sRelated persons%s\n' % (self.BOLD, self.NC)
@ -57,6 +53,7 @@ class MovieInfoFormatter(IFormatter):
result += '\n%sOther titles%s\n' % (self.BOLD, self.NC) result += '\n%sOther titles%s\n' % (self.BOLD, self.NC)
for t in obj.other_titles: for t in obj.other_titles:
result += ' * %s\n' % t result += ' * %s\n' % t
if obj.description != NotAvailable:
result += '\n%sDescription%s\n' % (self.BOLD, self.NC) result += '\n%sDescription%s\n' % (self.BOLD, self.NC)
result += '%s'%obj.description result += '%s'%obj.description
return result return result
@ -69,13 +66,16 @@ class MovieListFormatter(PrettyFormatter):
return obj.original_title return obj.original_title
def get_description(self, obj): def get_description(self, obj):
date_str = obj.release_date date_str = ''
if obj.release_date != NotAvailable: if obj.release_date != NotAvailable:
date_str = obj.release_date.strftime('%Y-%m-%d') date_str = 'released: %s, '%obj.release_date.strftime('%Y-%m-%d')
duration_suffix = '' duration = ''
if obj.duration != NotAvailable: if obj.duration != NotAvailable:
duration_suffix = 'min' duration = 'duration: %smin, '%obj.duration
return 'Released: %s (note: %s, duration: %s%s)' % (date_str, obj.note, obj.duration, duration_suffix) note = ''
if obj.note != NotAvailable:
note = 'note: %s, '%obj.note
return ('%s %s %s' % (date_str, note, duration)).strip(', ')
def yearsago(years, from_date=None): def yearsago(years, from_date=None):
if from_date is None: if from_date is None:
@ -103,7 +103,9 @@ class PersonInfoFormatter(IFormatter):
def format_obj(self, obj, alias): def format_obj(self, obj, alias):
result = u'%s%s%s\n' % (self.BOLD, obj.name, self.NC) result = u'%s%s%s\n' % (self.BOLD, obj.name, self.NC)
result += 'ID: %s\n' % obj.fullid result += 'ID: %s\n' % obj.fullid
if obj.real_name != NotAvailable:
result += 'Real name: %s\n' % obj.real_name result += 'Real name: %s\n' % obj.real_name
if obj.birth_place != NotAvailable:
result += 'Birth place: %s\n' % obj.birth_place result += 'Birth place: %s\n' % obj.birth_place
if obj.birth_date != NotAvailable: if obj.birth_date != NotAvailable:
result += 'Birth date: %s\n' % obj.birth_date.strftime('%Y-%m-%d') result += 'Birth date: %s\n' % obj.birth_date.strftime('%Y-%m-%d')
@ -113,9 +115,9 @@ class PersonInfoFormatter(IFormatter):
else: else:
age = num_years(obj.birth_date) age = num_years(obj.birth_date)
result += 'Age: %s\n' % age result += 'Age: %s\n' % age
else: if obj.gender != NotAvailable:
result += 'Birth date: %s\n' % obj.birth_date
result += 'Gender: %s\n' % obj.gender result += 'Gender: %s\n' % obj.gender
if obj.nationality != NotAvailable:
result += 'Nationality: %s\n' % obj.nationality result += 'Nationality: %s\n' % obj.nationality
if obj.roles: if obj.roles:
result += '\n%sRelated movies%s\n' % (self.BOLD, self.NC) result += '\n%sRelated movies%s\n' % (self.BOLD, self.NC)
@ -123,6 +125,7 @@ class PersonInfoFormatter(IFormatter):
result += ' -- %s\n' % role result += ' -- %s\n' % role
for movie in lmovies: for movie in lmovies:
result += ' * %s\n' % movie result += ' * %s\n' % movie
if obj.short_biography != NotAvailable:
result += '\n%sBiography%s\n' % (self.BOLD, self.NC) result += '\n%sBiography%s\n' % (self.BOLD, self.NC)
result += '%s'%obj.short_biography result += '%s'%obj.short_biography
return result return result
@ -135,11 +138,19 @@ class PersonListFormatter(PrettyFormatter):
return obj.name return obj.name
def get_description(self, obj): def get_description(self, obj):
age = ''
if obj.birth_date != NotAvailable and obj.death_date == NotAvailable: if obj.birth_date != NotAvailable and obj.death_date == NotAvailable:
age = num_years(obj.birth_date) age = 'age: %s'%num_years(obj.birth_date)
else: gender = ''
age = NotAvailable if obj.gender != NotAvailable:
return 'Real name: %s (age: %s, nationality: %s, gender: %s)' % (obj.real_name, age, obj.nationality, obj.gender) gender = 'gender: %s, '%obj.gender
real_name = ''
if obj.real_name != NotAvailable:
real_name = 'real name: %s, '%obj.real_name
nationality = ''
if obj.nationality != NotAvailable:
nationality = 'nationality: %s, '%obj.nationality
return ('%s%s%s%s' % (real_name, age, nationality, gender)).strip(' ,')
class Cineoob(ReplApplication): class Cineoob(ReplApplication):