mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Finish the 'rating in template' job. Make save_to_disk divide them by two.
This commit is contained in:
parent
1ec50e9d43
commit
29b9dfa8bb
@ -563,8 +563,10 @@ class Metadata(object):
|
||||
def format_tags(self):
|
||||
return u', '.join([unicode(t) for t in sorted(self.tags, key=sort_key)])
|
||||
|
||||
def format_rating(self):
|
||||
return unicode(self.rating)
|
||||
def format_rating(self, v = None):
|
||||
if v is None:
|
||||
return unicode(self.rating/2)
|
||||
return unicode(v/2)
|
||||
|
||||
def format_field(self, key, series_with_index=True):
|
||||
'''
|
||||
|
@ -211,6 +211,8 @@ def get_components(template, mi, id, timefmt='%b %Y', length=250,
|
||||
format_args[key] = strftime(timefmt, format_args[key].timetuple())
|
||||
elif cm['datatype'] == 'bool':
|
||||
format_args[key] = _('yes') if format_args[key] else _('no')
|
||||
elif cm['datatype'] == 'rating':
|
||||
format_args[key] = mi.format_rating(format_args[key])
|
||||
elif cm['datatype'] in ['int', 'float']:
|
||||
if format_args[key] != 0:
|
||||
format_args[key] = unicode(format_args[key])
|
||||
|
Loading…
x
Reference in New Issue
Block a user