jenkins-bot submitted this change.

View Change

Approvals: Mpaa: Looks good to me, approved jenkins-bot: Verified
[cleanup] remove desupported txtlib.TEMP_REGEX

Change-Id: Ifa430ce119d0e77e9e997cea99c5e7be6f8e89cd
---
M pywikibot/textlib.py
M tests/textlib_tests.py
2 files changed, 1 insertion(+), 50 deletions(-)

diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 972c290..d7945db 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -26,7 +26,6 @@
from pywikibot.tools import (
deprecate_arg,
deprecated,
- DeprecatedRegex,
issue_deprecation_warning,
)

@@ -46,22 +45,6 @@
r'{{(?:msg:)?(?P<name>[^{\|]+?)'
r'(?:\|(?P<params>[^{]+?(?:{[^{]+?}[^{]*?)?)?)?}}')

-# This template is a more inclusive template matching algorithm
-# that allows system variables, but does not match nested templates.
-# It exists for backwards compatibility to the old 'TEMP_REGEX'
-# which was the _ETP_REGEX.
-TEMP_REGEX = DeprecatedRegex(
- r"""
- {{\s*(?:msg:\s*)?
- (?P<name>[^{\|]+?)\s*
- (?:\|(?P<params>[^{]*
- (?:(?:{}|{{[A-Z]+(?:\:[^}])?}}|{{{[^}]+}}}) [^{]*)*
- )?
- )?
- }}
- """, re.VERBOSE, 'textlib.TEMP_REGEX', 'textlib.NESTED_TEMPLATE_REGEX',
- since='20150212')
-
# The regex below collects nested templates, providing simpler
# identification of templates used at the top-level of wikitext.
# It doesn't match {{{1|...}}}, however it also does not match templates
diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py
index b647ab6..e3bdbd9 100644
--- a/tests/textlib_tests.py
+++ b/tests/textlib_tests.py
@@ -5,8 +5,6 @@
#
# Distributed under the terms of the MIT license.
#
-from __future__ import absolute_import, division, unicode_literals
-
import codecs
from collections import OrderedDict
import functools
@@ -18,7 +16,6 @@

from pywikibot.site import _IWEntry
from pywikibot.textlib import _MultiTemplateMatchBuilder, extract_sections
-from pywikibot.tools import suppress_warnings
from pywikibot import UnknownSite

from tests.aspects import (
@@ -591,7 +588,7 @@
[(None, OrderedDict())])

def test_regexes(self):
- """Test _ETP_REGEX, NESTED_TEMPLATE_REGEX and TEMP_REGEX."""
+ """Test _ETP_REGEX and NESTED_TEMPLATE_REGEX."""
func = textlib._ETP_REGEX.search

self.assertIsNotNone(func('{{{1}}}'))
@@ -623,35 +620,6 @@
self.assertIsNone(func('{{a|{{c}} }}'))
self.assertIsNone(func('{{a|{{c|d}} }}'))

- with suppress_warnings('textlib.TEMP_REGEX is deprecated'):
- func = textlib.TEMP_REGEX.search
-
- self.assertIsNotNone(func('{{{1}}}'))
- self.assertIsNotNone(func('{{a|b={{c}} }}'))
- self.assertIsNotNone(func('{{a|b={{c|d=1}} }}'))
- self.assertIsNotNone(func('{{a|{{c}} }}'))
- self.assertIsNotNone(func('{{a|{{c|d}} }}'))
-
- with suppress_warnings('textlib.TEMP_REGEX is deprecated'):
- func = textlib.TEMP_REGEX.match
-
- self.assertIsNotNone(func('{{#if:foo}}'))
- self.assertIsNotNone(func('{{foo:}}'))
-
- self.assertIsNotNone(func('{{CURRENTYEAR}}'))
- self.assertIsNotNone(func('{{1}}'))
-
- self.assertIsNotNone(func('{{a|b={{CURRENTYEAR}} }}'))
- self.assertIsNotNone(func('{{a|b={{{1}}} }}'))
-
- self.assertIsNone(func('{{a|b={{c}} }}'))
- self.assertIsNone(func('{{a|b={{c|d=1}} }}'))
- self.assertIsNotNone(func('{{a|b={} }}'))
- self.assertIsNone(func('{{:a|b={{c|d=1}} }}'))
-
- self.assertIsNone(func('{{a|{{c}} }}'))
- self.assertIsNone(func('{{a|{{c|d}} }}'))
-
func = textlib.NESTED_TEMPLATE_REGEX.search

# Numerically named templates are rejected

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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ifa430ce119d0e77e9e997cea99c5e7be6f8e89cd
Gerrit-Change-Number: 630642
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Mpaa <mpaa.wiki@gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged