jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1022557?usp=email )
Change subject: [IMPR] Permit strings as exceptions for fixes ......................................................................
[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(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
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'),