jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[IMPR] Permit strings as exceptions for fixes

In other words, allow:

fixes['key'] = {
'exceptions': {
'text-contains': 'skip this text',
},
'replacements': [
...
],
}

Previously, a string was interpreted as a sequence (list)
of characters, each being a pattern to search for. Which
would cause silent skipping of pages.

Change-Id: I0f4d01fcf96f6b22d3ddc5970138ef4db8259f85
---
M scripts/replace.py
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/scripts/replace.py b/scripts/replace.py
index 5a809f4..f31fd40 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -178,6 +178,8 @@
'title', 'require-title', 'text-contains', 'inside']:
if exceptionCategory in exceptions:
patterns = exceptions[exceptionCategory]
+ if isinstance(patterns, str):
+ patterns = [patterns]
if not use_regex:
patterns = [re.escape(pattern) for pattern in patterns]
patterns = [re.compile(pattern, flags) for pattern in patterns]
@@ -1030,9 +1032,9 @@
if not generators_given and 'generator' in fix:
gen_args = fix['generator']
if isinstance(gen_args, str):
- gen_args = [gen_args]
- for gen_arg in gen_args:
- genFactory.handle_arg(gen_arg)
+ genFactory.handle_arg(gen_args)
+ else:
+ genFactory.handle_args(gen_args)
replacement_set = ReplacementList(fix.get('regex'),
fix.get('exceptions'),
fix.get('nocase'),

To view, visit change 1022557. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I0f4d01fcf96f6b22d3ddc5970138ef4db8259f85
Gerrit-Change-Number: 1022557
Gerrit-PatchSet: 2
Gerrit-Owner: Matěj Suchánek <matejsuchanek97@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged