1
0
Fork 0

Fix and refactor prepare_outtmpl

The following tests would have failed previously:
%(id)d %(id)r
%(ext)s-%(ext|def)d
%(width|)d
%(id)r %(height)r
%(formats.0)r
%s
This commit is contained in:
pukkandan 2021-06-03 23:30:38 +05:30
commit 752cda3880
No known key found for this signature in database
GPG key ID: 0F00D95A001F4698
6 changed files with 194 additions and 162 deletions

View file

@ -4393,15 +4393,17 @@ OUTTMPL_TYPES = {
# As of [1] format syntax is:
# %[mapping_key][conversion_flags][minimum_width][.precision][length_modifier]type
# 1. https://docs.python.org/2/library/stdtypes.html#string-formatting
FORMAT_RE = r'''(?x)
STR_FORMAT_RE = r'''(?x)
(?<!%)
%
\({0}\) # mapping key
(?:[#0\-+ ]+)? # conversion flags (optional)
(?:\d+)? # minimum field width (optional)
(?:\.\d+)? # precision (optional)
[hlL]? # length modifier (optional)
(?P<type>[diouxXeEfFgGcrs%]) # conversion type
(?P<has_key>\((?P<key>{0})\))? # mapping key
(?P<format>
(?:[#0\-+ ]+)? # conversion flags (optional)
(?:\d+)? # minimum field width (optional)
(?:\.\d+)? # precision (optional)
[hlL]? # length modifier (optional)
[diouxXeEfFgGcrs] # conversion type
)
'''