From 9c99f3a1019eaefce0284b5aa09c570b3f6d8d6c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 11 Apr 2020 16:19:05 +0530 Subject: [PATCH] =?UTF-8?q?py3=20compat:=20Fixes=20#1132=20(Fix=20python?= =?UTF-8?q?=203=20compatibility:=20template=20formatter:=20when=20no=20key?= =?UTF-8?q?=20is=20used=20in=20a=20template=20an=20=E2=80=A6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/calibre/ebooks/metadata/book/formatter.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/metadata/book/formatter.py b/src/calibre/ebooks/metadata/book/formatter.py index 0943828f76..6d504124ed 100644 --- a/src/calibre/ebooks/metadata/book/formatter.py +++ b/src/calibre/ebooks/metadata/book/formatter.py @@ -8,6 +8,7 @@ __copyright__ = '2013, Kovid Goyal ' 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 - -