images: allow nested bracket in filename pattern
This commit is contained in:
parent
c7af69f893
commit
146856f66d
|
@ -277,7 +277,7 @@ invalid_filename_chars = '<>:"/\\|?*\n'
|
||||||
invalid_filename_prefix = ' '
|
invalid_filename_prefix = ' '
|
||||||
invalid_filename_postfix = ' .'
|
invalid_filename_postfix = ' .'
|
||||||
re_nonletters = re.compile(r'[\s' + string.punctuation + ']+')
|
re_nonletters = re.compile(r'[\s' + string.punctuation + ']+')
|
||||||
re_pattern = re.compile(r"([^\[\]]+|\[([^]]+)]|[\[\]]*)")
|
re_pattern = re.compile(r"(.*?)(?:\[([^\[\]]+)\]|$)")
|
||||||
re_pattern_arg = re.compile(r"(.*)<([^>]*)>$")
|
re_pattern_arg = re.compile(r"(.*)<([^>]*)>$")
|
||||||
max_filename_part_length = 128
|
max_filename_part_length = 128
|
||||||
|
|
||||||
|
@ -362,9 +362,9 @@ class FilenameGenerator:
|
||||||
|
|
||||||
for m in re_pattern.finditer(x):
|
for m in re_pattern.finditer(x):
|
||||||
text, pattern = m.groups()
|
text, pattern = m.groups()
|
||||||
|
res += text
|
||||||
|
|
||||||
if pattern is None:
|
if pattern is None:
|
||||||
res += text
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
pattern_args = []
|
pattern_args = []
|
||||||
|
@ -385,12 +385,9 @@ class FilenameGenerator:
|
||||||
print(f"Error adding [{pattern}] to filename", file=sys.stderr)
|
print(f"Error adding [{pattern}] to filename", file=sys.stderr)
|
||||||
print(traceback.format_exc(), file=sys.stderr)
|
print(traceback.format_exc(), file=sys.stderr)
|
||||||
|
|
||||||
if replacement is None:
|
if replacement is not None:
|
||||||
res += f'[{pattern}]'
|
|
||||||
else:
|
|
||||||
res += str(replacement)
|
res += str(replacement)
|
||||||
|
continue
|
||||||
continue
|
|
||||||
|
|
||||||
res += f'[{pattern}]'
|
res += f'[{pattern}]'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue