mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
Test the 'test' function. Add 're' function and test it.
This commit is contained in:
parent
5297562383
commit
25905a349c
@ -43,6 +43,9 @@ class TemplateFormatter(string.Formatter):
|
||||
else:
|
||||
return val
|
||||
|
||||
def _re(self, val, pattern, replacement):
|
||||
return re.sub(pattern, replacement, val)
|
||||
|
||||
functions = {
|
||||
'uppercase' : (0, lambda s,x: x.upper()),
|
||||
'lowercase' : (0, lambda s,x: x.lower()),
|
||||
@ -50,8 +53,9 @@ class TemplateFormatter(string.Formatter):
|
||||
'capitalize' : (0, lambda s,x: x.capitalize()),
|
||||
'ifempty' : (1, _ifempty),
|
||||
'lookup' : (2, _lookup),
|
||||
're' : (2, _re),
|
||||
'shorten' : (3, _shorten),
|
||||
'test' : (2, _lookup),
|
||||
'test' : (2, _test),
|
||||
}
|
||||
|
||||
format_string_re = re.compile(r'^(.*)\|(.*)\|(.*)$')
|
||||
|
Loading…
x
Reference in New Issue
Block a user