mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04: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
@ -8,6 +8,7 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
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 @@ class SafeFormat(TemplateFormatter):
|
||||
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 @@ class SafeFormat(TemplateFormatter):
|
||||
if v == '':
|
||||
return ''
|
||||
return v
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user