|
30 | 30 | # ---------------------------------------------------------------------- |
31 | 31 |
|
32 | 32 | # match tail after wikilink |
33 | | -tailRE = re.compile('\w+') |
| 33 | +tailRE = re.compile(r'\w+') |
34 | 34 | syntaxhighlight = re.compile('<syntaxhighlight .*?>(.*?)</syntaxhighlight>', re.DOTALL) |
35 | 35 |
|
36 | 36 | ## PARAMS #################################################################### |
@@ -168,8 +168,8 @@ def clean(extractor, text, expand_templates=False, html_safe=True): |
168 | 168 | text = text.replace('\t', ' ') |
169 | 169 | text = spaces.sub(' ', text) |
170 | 170 | text = dots.sub('...', text) |
171 | | - text = re.sub(u' (,:\.\)\]»)', r'\1', text) |
172 | | - text = re.sub(u'(\[\(«) ', r'\1', text) |
| 171 | + text = re.sub(r' (,:\.\)\]»)', r'\1', text) |
| 172 | + text = re.sub(r'(\[\(«) ', r'\1', text) |
173 | 173 | text = re.sub(r'\n\W+?\n', '\n', text, flags=re.U) # lines with only punctuations |
174 | 174 | text = text.replace(',,', ',').replace(',.', '.') |
175 | 175 | if html_safe: |
@@ -380,7 +380,7 @@ def dropSpans(spans, text): |
380 | 380 | # as well as U+3000 is IDEOGRAPHIC SPACE for bug 19052 |
381 | 381 | EXT_LINK_URL_CLASS = r'[^][<>"\x00-\x20\x7F\s]' |
382 | 382 | ExtLinkBracketedRegex = re.compile( |
383 | | - '(?i)\[((' + '|'.join(wgUrlProtocols) + ')' + EXT_LINK_URL_CLASS + r'+)\s*([^\]\x00-\x08\x0a-\x1F]*?)\]', |
| 383 | + r'(?i)\[((' + '|'.join(wgUrlProtocols) + ')' + EXT_LINK_URL_CLASS + r'+)\s*([^\]\x00-\x08\x0a-\x1F]*?)\]', |
384 | 384 | re.S | re.U) |
385 | 385 | EXT_IMAGE_REGEX = re.compile( |
386 | 386 | r"""(?i)^(http://|https://)([^][<>"\x00-\x20\x7F\s]+) |
@@ -734,7 +734,7 @@ def fixup(m): |
734 | 734 | except: |
735 | 735 | return text # leave as is |
736 | 736 |
|
737 | | - return re.sub("&#?(\w+);", fixup, text) |
| 737 | + return re.sub(r"&#?(\w+);", fixup, text) |
738 | 738 |
|
739 | 739 |
|
740 | 740 | # Match HTML comments |
@@ -1024,7 +1024,7 @@ def extract(self, out, html_safe=True): |
1024 | 1024 | maxParameterRecursionLevels = 16 |
1025 | 1025 |
|
1026 | 1026 | # check for template beginning |
1027 | | - reOpen = re.compile('(?<!{){{(?!{)', re.DOTALL) |
| 1027 | + reOpen = re.compile(r'(?<!{){{(?!{)', re.DOTALL) |
1028 | 1028 |
|
1029 | 1029 | def expandTemplates(self, wikitext): |
1030 | 1030 | """ |
@@ -1434,11 +1434,11 @@ def findMatchingBraces(text, ldelim=0): |
1434 | 1434 | # {{{link|{{ucfirst:{{{1}}}}}} interchange}}} |
1435 | 1435 |
|
1436 | 1436 | if ldelim: # 2-3 |
1437 | | - reOpen = re.compile('[{]{%d,}' % ldelim) # at least ldelim |
1438 | | - reNext = re.compile('[{]{2,}|}{2,}') # at least 2 open or close bracces |
| 1437 | + reOpen = re.compile(r'[{]{%d,}' % ldelim) # at least ldelim |
| 1438 | + reNext = re.compile(r'[{]{2,}|}{2,}') # at least 2 open or close bracces |
1439 | 1439 | else: |
1440 | | - reOpen = re.compile('{{2,}|\[{2,}') |
1441 | | - reNext = re.compile('{{2,}|}{2,}|\[{2,}|]{2,}') # at least 2 |
| 1440 | + reOpen = re.compile(r'{{2,}|\[{2,}') |
| 1441 | + reNext = re.compile(r'{{2,}|}{2,}|\[{2,}|]{2,}') # at least 2 |
1442 | 1442 |
|
1443 | 1443 | cur = 0 |
1444 | 1444 | while True: |
@@ -1582,7 +1582,7 @@ def fullyQualifiedTemplateTitle(templateTitle): |
1582 | 1582 | # Leading colon by itself implies main namespace, so strip this colon |
1583 | 1583 | return ucfirst(templateTitle[1:]) |
1584 | 1584 | else: |
1585 | | - m = re.match('([^:]*)(:.*)', templateTitle) |
| 1585 | + m = re.match(r'([^:]*)(:.*)', templateTitle) |
1586 | 1586 | if m: |
1587 | 1587 | # colon found but not in the first position - check if it |
1588 | 1588 | # designates a known namespace |
@@ -1689,7 +1689,7 @@ def sharp_ifeq(lvalue, rvalue, valueIfTrue, valueIfFalse=None, *args): |
1689 | 1689 |
|
1690 | 1690 |
|
1691 | 1691 | def sharp_iferror(test, then='', Else=None, *args): |
1692 | | - if re.match('<(?:strong|span|p|div)\s(?:[^\s>]*\s+)*?class="(?:[^"\s>]*\s+)*?error(?:\s[^">]*)?"', test): |
| 1692 | + if re.match(r'<(?:strong|span|p|div)\s(?:[^\s>]*\s+)*?class="(?:[^"\s>]*\s+)*?error(?:\s[^">]*)?"', test): |
1693 | 1693 | return then |
1694 | 1694 | elif Else is None: |
1695 | 1695 | return test.strip() |
@@ -1860,7 +1860,7 @@ def define_template(title, page): |
1860 | 1860 | # title = normalizeTitle(title) |
1861 | 1861 |
|
1862 | 1862 | # check for redirects |
1863 | | - m = re.match('#REDIRECT.*?\[\[([^\]]*)]]', page[0], re.IGNORECASE) |
| 1863 | + m = re.match(r'#REDIRECT.*?\[\[([^\]]*)]]', page[0], re.IGNORECASE) |
1864 | 1864 | if m: |
1865 | 1865 | redirects[title] = m.group(1) # normalizeTitle(m.group(1)) |
1866 | 1866 | return |
|
0 commit comments