From 88e962ae39d2d496815705ee51b4c27f57ebe5f9 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 5 Aug 2010 11:23:54 -0600 Subject: [PATCH] Save to disk/send to device templates: Always render {series_index} as an empty string when the book has no series. Fixes #6409 (Make series_index empty string if series empty string) --- src/calibre/library/save_to_disk.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calibre/library/save_to_disk.py b/src/calibre/library/save_to_disk.py index 845ec0590d..e94d3b35d3 100644 --- a/src/calibre/library/save_to_disk.py +++ b/src/calibre/library/save_to_disk.py @@ -125,6 +125,8 @@ def get_components(template, mi, id, timefmt='%b %Y', length=250, format_args['series'] = mi.series if mi.series_index is not None: format_args['series_index'] = mi.format_series_index() + else: + template = re.sub(r'\{series_index[^}]*?\}', '', template) if mi.rating is not None: format_args['rating'] = mi.format_rating() if mi.isbn: