mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 04:03:52 +02:00
py3 compat: Fixes #1132 (Fix python 3 compatibility: template formatter: when no key is used in a template an …)
This commit is contained in:
parent
d61273b7cd
commit
9c99f3a101
1 changed files with 2 additions and 3 deletions
|
|
@ -8,6 +8,7 @@
|
|||
from calibre.ebooks.metadata.book import TOP_LEVEL_IDENTIFIERS, ALL_METADATA_FIELDS
|
||||
|
||||
from calibre.utils.formatter import TemplateFormatter
|
||||
from numbers import Number
|
||||
|
||||
|
||||
class SafeFormat(TemplateFormatter):
|
||||
|
|
@ -16,7 +17,7 @@ def __init__(self):
|
|||
TemplateFormatter.__init__(self)
|
||||
|
||||
def get_value(self, orig_key, args, kwargs):
|
||||
if not orig_key:
|
||||
if not orig_key or isinstance(orig_key, Number):
|
||||
return ''
|
||||
key = orig_key = orig_key.lower()
|
||||
if (key != 'title_sort' and key not in TOP_LEVEL_IDENTIFIERS and
|
||||
|
|
@ -42,5 +43,3 @@ def get_value(self, orig_key, args, kwargs):
|
|||
if v == '':
|
||||
return ''
|
||||
return v
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue