From 43b51ed33470570c4cc67aa70bfef55fa738fb50 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 5 Aug 2010 12:05:54 -0600 Subject: [PATCH] When generating template based filenames replace multiple spaces with a single space --- src/calibre/library/save_to_disk.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/library/save_to_disk.py b/src/calibre/library/save_to_disk.py index e94d3b35d3..8bbdbb0932 100644 --- a/src/calibre/library/save_to_disk.py +++ b/src/calibre/library/save_to_disk.py @@ -99,7 +99,8 @@ def preprocess_template(template): def safe_format(x, format_args): try: - return x.format(**format_args).strip() + ans = x.format(**format_args).strip() + return re.sub(r'\s+', ' ', ans) except IndexError: # Thrown if user used [] and index is out of bounds pass except AttributeError: # Thrown if user used a non existing attribute