Adjust filename suffix matching for Qt 5.12
https://codereview.qt-project.org/#/c/247517/ https://chromium-review.googlesource.com/c/chromium/src/+/1278137 https://cs.chromium.org/chromium/src/base/time/time_to_iso8601.cc Fixes #4478 Fixes #4580
This commit is contained in:
parent
d97a186992
commit
04764b9c39
@ -180,7 +180,21 @@ def _get_suggested_filename(path):
|
|||||||
See https://bugreports.qt.io/browse/QTBUG-56978
|
See https://bugreports.qt.io/browse/QTBUG-56978
|
||||||
"""
|
"""
|
||||||
filename = os.path.basename(path)
|
filename = os.path.basename(path)
|
||||||
filename = re.sub(r'\([0-9]+\)(?=\.|$)', '', filename)
|
|
||||||
|
suffix_re = re.compile(r"""
|
||||||
|
\ ? # Optional space between filename and suffix
|
||||||
|
(
|
||||||
|
# Numerical suffix
|
||||||
|
\([0-9]+\)
|
||||||
|
|
|
||||||
|
# ISO-8601 suffix
|
||||||
|
# https://cs.chromium.org/chromium/src/base/time/time_to_iso8601.cc
|
||||||
|
\ -\ \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z
|
||||||
|
)
|
||||||
|
(?=\.|$) # Begin of extension, or filename without extension
|
||||||
|
""", re.VERBOSE)
|
||||||
|
|
||||||
|
filename = suffix_re.sub('', filename)
|
||||||
if not qtutils.version_check('5.9', compiled=False):
|
if not qtutils.version_check('5.9', compiled=False):
|
||||||
# https://bugreports.qt.io/browse/QTBUG-58155
|
# https://bugreports.qt.io/browse/QTBUG-58155
|
||||||
filename = urllib.parse.unquote(filename)
|
filename = urllib.parse.unquote(filename)
|
||||||
|
@ -30,6 +30,8 @@ from helpers import utils
|
|||||||
@pytest.mark.parametrize('path, expected', [
|
@pytest.mark.parametrize('path, expected', [
|
||||||
(os.path.join('subfolder', 'foo'), 'foo'),
|
(os.path.join('subfolder', 'foo'), 'foo'),
|
||||||
('foo(1)', 'foo'),
|
('foo(1)', 'foo'),
|
||||||
|
('foo (1)', 'foo'),
|
||||||
|
('foo - 1970-01-01T00:00:00.000Z', 'foo'),
|
||||||
('foo(a)', 'foo(a)'),
|
('foo(a)', 'foo(a)'),
|
||||||
('foo1', 'foo1'),
|
('foo1', 'foo1'),
|
||||||
pytest.param('foo%20bar', 'foo bar', marks=utils.qt58),
|
pytest.param('foo%20bar', 'foo bar', marks=utils.qt58),
|
||||||
|
Loading…
Reference in New Issue
Block a user