jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/690542 )
Change subject: [W0212] Rename _MultiTemplateMatchBuilder to MultiTemplateMatchBuilder ......................................................................
[W0212] Rename _MultiTemplateMatchBuilder to MultiTemplateMatchBuilder
I did not find any reason why textlib.MultiTemplateMatchBuilder is private
Change-Id: I7d45d2edb36c4898975001d138cfb0e53ddb8efc --- M pywikibot/cosmetic_changes.py M pywikibot/textlib.py M scripts/category_redirect.py M scripts/checkimages.py M scripts/template.py M tests/template_bot_tests.py M tests/textlib_tests.py 7 files changed, 19 insertions(+), 19 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py index 8d2270c..6df0bb8 100755 --- a/pywikibot/cosmetic_changes.py +++ b/pywikibot/cosmetic_changes.py @@ -64,8 +64,8 @@ from pywikibot.page import url2unicode from pywikibot.textlib import ( FILE_LINK_REGEX, + MultiTemplateMatchBuilder, _get_regexes, - _MultiTemplateMatchBuilder, ) from pywikibot.tools import ( deprecated, @@ -812,7 +812,7 @@ def replaceDeprecatedTemplates(self, text): """Replace deprecated templates.""" exceptions = ['comment', 'math', 'nowiki', 'pre'] - builder = _MultiTemplateMatchBuilder(self.site) + builder = MultiTemplateMatchBuilder(self.site)
if self.site.family.name in deprecatedTemplates \ and self.site.code in deprecatedTemplates[self.site.family.name]: diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py index b278865..ae7060d 100644 --- a/pywikibot/textlib.py +++ b/pywikibot/textlib.py @@ -156,7 +156,7 @@ return html.unescape(s)
-class _MultiTemplateMatchBuilder: +class MultiTemplateMatchBuilder:
"""Build template matcher."""
diff --git a/scripts/category_redirect.py b/scripts/category_redirect.py index 4945493..14216ac 100755 --- a/scripts/category_redirect.py +++ b/scripts/category_redirect.py @@ -304,9 +304,9 @@ with open(self.datafile + '.bak', 'wb') as f: pickle.dump(self.record, f, protocol=config.pickle_protocol) # regex to match soft category redirects - # TODO: enhance and use textlib._MultiTemplateMatchBuilder - # note that any templates containing optional "category:" are - # incorrect and will be fixed by the bot + # TODO: enhance and use textlib.MultiTemplateMatchBuilder + # note that any templates containing optional "category:" are + # incorrect and will be fixed by the bot template_regex = re.compile( r"""{{\s*(?:%(prefix)s\s*:\s*)? # optional "template:" (?:%(template)s)\s*| # catredir template name diff --git a/scripts/checkimages.py b/scripts/checkimages.py index 95c1086..178c589 100755 --- a/scripts/checkimages.py +++ b/scripts/checkimages.py @@ -1342,7 +1342,7 @@
def isTagged(self) -> bool: """Understand if a file is already tagged or not.""" - # TODO: enhance and use textlib._MultiTemplateMatchBuilder + # TODO: enhance and use textlib.MultiTemplateMatchBuilder # Is the image already tagged? If yes, no need to double-check, skip no_license = i18n.translate(self.site, txt_find) if not no_license: diff --git a/scripts/template.py b/scripts/template.py index f87d82b..a6cbf72 100755 --- a/scripts/template.py +++ b/scripts/template.py @@ -161,7 +161,7 @@
replacements = [] exceptions = {} - builder = textlib._MultiTemplateMatchBuilder(self.site) + builder = textlib.MultiTemplateMatchBuilder(self.site) for old, new in self.templates.items(): template_regex = builder.pattern(old)
@@ -285,7 +285,7 @@ old_templates.append(old_template)
if xmlfilename: - builder = textlib._MultiTemplateMatchBuilder(site) + builder = textlib.MultiTemplateMatchBuilder(site) predicate = builder.search_any_predicate(old_templates)
gen = XMLDumpPageGenerator( diff --git a/tests/template_bot_tests.py b/tests/template_bot_tests.py index 7328486..48b4e1b 100644 --- a/tests/template_bot_tests.py +++ b/tests/template_bot_tests.py @@ -8,7 +8,7 @@
import pywikibot from pywikibot.pagegenerators import XMLDumpPageGenerator -from pywikibot.textlib import _MultiTemplateMatchBuilder +from pywikibot.textlib import MultiTemplateMatchBuilder from tests import join_xml_data_path from tests.aspects import TestCase
@@ -25,7 +25,7 @@ def generator(self, title, xml='article-pear-0.10.xml'): """Return XMLDumpPageGenerator list for a given template title.""" template = pywikibot.Page(self.site, title, ns=10) - builder = _MultiTemplateMatchBuilder(self.site) + builder = MultiTemplateMatchBuilder(self.site) predicate = builder.search_any_predicate([template]) gen = XMLDumpPageGenerator( filename=join_xml_data_path(xml), @@ -53,7 +53,7 @@ """Test pages with one of many matches.""" template1 = pywikibot.Page(self.site, 'Template:stack begin') template2 = pywikibot.Page(self.site, 'Template:foobar') - builder = _MultiTemplateMatchBuilder(self.site) + builder = MultiTemplateMatchBuilder(self.site)
predicate = builder.search_any_predicate([template1, template2]) gen = XMLDumpPageGenerator( diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py index fe3ece0..6904e2c 100644 --- a/tests/textlib_tests.py +++ b/tests/textlib_tests.py @@ -17,7 +17,7 @@ from pywikibot.backports import nullcontext from pywikibot.exceptions import UnknownSiteError from pywikibot.site._interwikimap import _IWEntry -from pywikibot.textlib import _MultiTemplateMatchBuilder, extract_sections +from pywikibot.textlib import MultiTemplateMatchBuilder, extract_sections from pywikibot.tools import suppress_warnings from tests import mock from tests.aspects import ( @@ -1470,7 +1470,7 @@
class TestMultiTemplateMatchBuilder(DefaultDrySiteTestCase):
- """Test _MultiTemplateMatchBuilder.""" + """Test MultiTemplateMatchBuilder."""
@classmethod def setUpClass(cls): @@ -1482,13 +1482,13 @@ def test_no_match(self): """Test text without any desired templates.""" string = 'The quick brown fox' - builder = _MultiTemplateMatchBuilder(self.site) + builder = MultiTemplateMatchBuilder(self.site) self.assertIsNone(re.search(builder.pattern('quick'), string))
def test_match(self): """Test text with one match without parameters.""" string = 'The {{quick}} brown fox' - builder = _MultiTemplateMatchBuilder(self.site) + builder = MultiTemplateMatchBuilder(self.site) self.assertIsNotNone(re.search(builder.pattern('quick'), string)) self.assertEqual(bool(re.search(builder.pattern('Quick'), string)), self._template_not_case_sensitive) @@ -1496,7 +1496,7 @@ def test_match_with_params(self): """Test text with one match with parameters.""" string = 'The {{quick|brown}} fox' - builder = _MultiTemplateMatchBuilder(self.site) + builder = MultiTemplateMatchBuilder(self.site) self.assertIsNotNone(re.search(builder.pattern('quick'), string)) self.assertEqual(bool(re.search(builder.pattern('Quick'), string)), self._template_not_case_sensitive) @@ -1504,7 +1504,7 @@ def test_match_msg(self): """Test text with {{msg:..}}.""" string = 'The {{msg:quick}} brown fox' - builder = _MultiTemplateMatchBuilder(self.site) + builder = MultiTemplateMatchBuilder(self.site) self.assertIsNotNone(re.search(builder.pattern('quick'), string)) self.assertEqual(bool(re.search(builder.pattern('Quick'), string)), self._template_not_case_sensitive) @@ -1513,7 +1513,7 @@ """Test pages with {{template:..}}.""" string = 'The {{%s:%s}} brown fox' template = 'template' - builder = _MultiTemplateMatchBuilder(self.site) + builder = MultiTemplateMatchBuilder(self.site) if self._template_not_case_sensitive: quick_list = ('quick', 'Quick') else:
pywikibot-commits@lists.wikimedia.org