jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1340630?usp=email )
Change subject: Reuse the case-insensitive tag-name pattern
......................................................................
Reuse the case-insensitive tag-name pattern
Build the case-insensitive name once and reuse it for the opening and
closing tags. Avoid traversing the tag name and constructing the same
regex fragment twice.
Change-Id: Icaa27ad99157f99f7e5973429c90410398f4ce17
---
M pywikibot/textlib.py
1 file changed, 3 insertions(+), 2 deletions(-)
Approvals:
Mahveotm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index f55eac5..14ac844 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -239,10 +239,11 @@
def _tag_pattern(tag_name: str) -> str:
"""Return a tag pattern for the given tag name."""
+ tag_pattern = ignore_case(tag_name)
return (
- rf'<{ignore_case(tag_name)}(?:>|\s+[^>]*(?<!/)>)' # start tag
+ rf'<{tag_pattern}(?:>|\s+[^>]*(?<!/)>)' # start tag
r'.*?' # contents
- rf'</{ignore_case(tag_name)}\s*>' # end tag
+ rf'</{tag_pattern}\s*>' # end tag
)
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1340630?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Icaa27ad99157f99f7e5973429c90410398f4ce17
Gerrit-Change-Number: 1340630
Gerrit-PatchSet: 1
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Mahveotm <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]