mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
When formatting ratings, do not have an unneccessary .0
This commit is contained in:
parent
867f8a4e83
commit
36da67e37b
@ -653,7 +653,7 @@ class Metadata(object):
|
|||||||
elif datatype == 'bool':
|
elif datatype == 'bool':
|
||||||
res = _('Yes') if res else _('No')
|
res = _('Yes') if res else _('No')
|
||||||
elif datatype == 'rating':
|
elif datatype == 'rating':
|
||||||
res = res/2.0
|
res = u'%.2g'%(res/2.0)
|
||||||
elif datatype in ['int', 'float']:
|
elif datatype in ['int', 'float']:
|
||||||
try:
|
try:
|
||||||
fmt = cmeta['display'].get('number_format', None)
|
fmt = cmeta['display'].get('number_format', None)
|
||||||
@ -693,7 +693,7 @@ class Metadata(object):
|
|||||||
elif datatype == 'datetime':
|
elif datatype == 'datetime':
|
||||||
res = format_date(res, fmeta['display'].get('date_format','dd MMM yyyy'))
|
res = format_date(res, fmeta['display'].get('date_format','dd MMM yyyy'))
|
||||||
elif datatype == 'rating':
|
elif datatype == 'rating':
|
||||||
res = res/2.0
|
res = u'%.2g'%(res/2.0)
|
||||||
elif key == 'size':
|
elif key == 'size':
|
||||||
res = human_readable(res)
|
res = human_readable(res)
|
||||||
return (name, unicode(res), orig_res, fmeta)
|
return (name, unicode(res), orig_res, fmeta)
|
||||||
@ -728,7 +728,8 @@ class Metadata(object):
|
|||||||
if not self.is_null('languages'):
|
if not self.is_null('languages'):
|
||||||
fmt('Languages', ', '.join(self.languages))
|
fmt('Languages', ', '.join(self.languages))
|
||||||
if self.rating is not None:
|
if self.rating is not None:
|
||||||
fmt('Rating', self.rating)
|
fmt('Rating', (u'%.2g'%(float(self.rating)/2.0)) if self.rating
|
||||||
|
else u'')
|
||||||
if self.timestamp is not None:
|
if self.timestamp is not None:
|
||||||
fmt('Timestamp', isoformat(self.timestamp))
|
fmt('Timestamp', isoformat(self.timestamp))
|
||||||
if self.pubdate is not None:
|
if self.pubdate is not None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user