From e8d46b6094d650a43b6347fe54235d4bb5640a34 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Fri, 20 Jun 2025 17:25:43 +0100 Subject: [PATCH] Fix a problem with the validation formatter causing problems in the Kobo driver. --- src/calibre/utils/formatter.py | 4 ++-- src/calibre/utils/formatter_functions.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/calibre/utils/formatter.py b/src/calibre/utils/formatter.py index 5c9985d86d..2c22c377d0 100644 --- a/src/calibre/utils/formatter.py +++ b/src/calibre/utils/formatter.py @@ -2033,9 +2033,9 @@ class ValidateFormatter(TemplateFormatter): def get_value(self, key, args, kwargs): return self._validation_string - def validate(self, x): + def validate(self, template): from calibre.ebooks.metadata.book.base import Metadata - return self.unsafe_format(x, {}, 'VALIDATE ERROR', Metadata('')) + return self.unsafe_format(template, {}, Metadata('')) validation_formatter = ValidateFormatter() diff --git a/src/calibre/utils/formatter_functions.py b/src/calibre/utils/formatter_functions.py index 1a5e018272..f09fdc2cc0 100644 --- a/src/calibre/utils/formatter_functions.py +++ b/src/calibre/utils/formatter_functions.py @@ -193,7 +193,10 @@ def only_in_gui_error(name): def get_database(mi, name): - proxy = mi.get('_proxy_metadata', None) + try: + proxy = mi.get('_proxy_metadata', None) + except Exception: + proxy = None if proxy is None: if name is not None: only_in_gui_error(name)