mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Template language: Fix zero valued series indices not formatting correctly
Fixes #1247348 [Template does not show correct result with series_index[0]](https://bugs.launchpad.net/calibre/+bug/1247348) Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
commit
0a6e52b034
@ -33,8 +33,7 @@ class SafeFormat(TemplateFormatter):
|
||||
b = self.book.get_user_metadata(key, False)
|
||||
except:
|
||||
b = None
|
||||
if b and ((b['datatype'] == 'int' and self.book.get(key, 0) == 0) or
|
||||
(b['datatype'] == 'float' and self.book.get(key, 0.0) == 0.0)):
|
||||
if b and b['datatype'] in {'int', 'float'} and self.book.get(key, None) is None:
|
||||
v = ''
|
||||
else:
|
||||
v = self.book.format_field(key, series_with_index=False)[1]
|
||||
|
@ -504,9 +504,12 @@ class FieldMetadata(dict):
|
||||
return [k for k in self._tb_cats.iterkeys() if self.is_ignorable_field(k)]
|
||||
|
||||
def is_series_index(self, key):
|
||||
m = self[key]
|
||||
return (m['datatype'] == 'float' and key.endswith('_index') and
|
||||
key[:-6] in self)
|
||||
try:
|
||||
m = self._tb_cats[key]
|
||||
return (m['datatype'] == 'float' and key.endswith('_index') and
|
||||
key[:-6] in self._tb_cats)
|
||||
except (KeyError, ValueError, TypeError, AttributeError):
|
||||
return False
|
||||
|
||||
def key_to_label(self, key):
|
||||
if 'label' not in self._tb_cats[key]:
|
||||
|
Loading…
x
Reference in New Issue
Block a user