jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/675309 )

Change subject: [IMPR] exclude expressions from parsed template in 
mwparserfromhell
......................................................................

[IMPR] exclude expressions from parsed template in mwparserfromhell

- If using mwparserfromhell for textlib.extract_templates_and_params
  function exclude expressions from parsed template
- Use ifilter_templates instead of creating a list
- Also require mwparserfromhell => 0.5 due to
  fixed Wikicode.matches()'s behavior on iterables

Bug: T71384
Change-Id: I9fe9b80694db71a05a28e22a743a343b853ec1d7
---
M pywikibot/textlib.py
M requirements.txt
M setup.py
3 files changed, 7 insertions(+), 5 deletions(-)

Approvals:
  Xqt: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index c7e7fb6..204bd68 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -1637,7 +1637,9 @@
     code = mwparserfromhell.parse(text)
     result = []

-    for template in code.filter_templates(recursive=True):
+    for template in code.ifilter_templates(
+            matches=lambda x: not x.name.lstrip().startswith('#'),
+            recursive=True):
         params = OrderedDict()
         for param in template.params:
             if strip:
diff --git a/requirements.txt b/requirements.txt
index de654f8..a1c915e 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -34,15 +34,15 @@

 # GUI
 Pillow >= 6.2.2, < 8.0.0 ; python_version < '3.6'
-Pillow >= 6.2.2 ; python_version >= '3.6' and python_version < '3.9'
+Pillow >= 6.2.2 ; python_version >= '3.6' and python_version < '3.9'
 Pillow >= 8.0.0 ; python_version >= '3.9'

 # core pagegenerators
 google >= 1.7
 sseclient >= 0.0.18,!=0.0.23,!=0.0.24

-# textlib.py and patrol.py
-mwparserfromhell>=0.3.3
+# textlib.py
+mwparserfromhell>=0.5.0

 # The mysql generator in pagegenerators depends on PyMySQL
 PyMySQL
diff --git a/setup.py b/setup.py
index a8378f4..0aff894 100644
--- a/setup.py
+++ b/setup.py
@@ -60,7 +60,7 @@
     'eventstreams': ['sseclient!=0.0.23,!=0.0.24,>=0.0.18'],
     'isbn': ['python-stdnum>=1.16'],
     'Google': ['google>=1.7'],
-    'mwparserfromhell': ['mwparserfromhell>=0.3.3'],
+    'mwparserfromhell': ['mwparserfromhell>=0.5.0'],
     'Tkinter': [  # vulnerability found in Pillow<6.2.2
         'Pillow>=6.2.2,<8.0.0;python_version<"3.6"',
         'Pillow>=6.2.2;python_version>="3.6" and python_version<"3.9"',

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/675309
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I9fe9b80694db71a05a28e22a743a343b853ec1d7
Gerrit-Change-Number: 675309
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: BenKurtovic <[email protected]>
Gerrit-Reviewer: Dalba <[email protected]>
Gerrit-Reviewer: Dvorapa <[email protected]>
Gerrit-Reviewer: Jean-Frédéric <[email protected]>
Gerrit-Reviewer: Lokal Profil <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to