From 7b1df14c362b7f1300e08aad6ae11a7fbd794589 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Mon, 4 Oct 2010 08:20:34 +0100 Subject: [PATCH] Remove escaping backslash in replacement string in formatter. --- src/calibre/utils/formatter.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calibre/utils/formatter.py b/src/calibre/utils/formatter.py index fdfd7b77c3..50c08977cd 100644 --- a/src/calibre/utils/formatter.py +++ b/src/calibre/utils/formatter.py @@ -82,6 +82,7 @@ class TemplateFormatter(string.Formatter): format_string_re = re.compile(r'^(.*)\|(.*)\|(.*)$') compress_spaces = re.compile(r'\s+') + backslash_comma_to_comma = re.compile(r'\\,') arg_parser = re.Scanner([ (r',', lambda x,t: ''), @@ -123,6 +124,7 @@ class TemplateFormatter(string.Formatter): field = fmt[colon:p] func = self.functions[field] args = self.arg_parser.scan(fmt[p+1:])[0] + args = [self.backslash_comma_to_comma.sub(',', a) for a in args] if (func[0] == 0 and (len(args) != 1 or args[0])) or \ (func[0] > 0 and func[0] != len(args)): raise ValueError('Incorrect number of arguments for function '+ fmt[0:p])