mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Remove escaping backslash in replacement string in formatter.
This commit is contained in:
parent
134bbcdbd0
commit
7b1df14c36
@ -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])
|
||||
|
Loading…
x
Reference in New Issue
Block a user