ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/ValBot/Python/check_intrawiki_section_links.py
(Generate patch)

Comparing ValBot/Python/check_intrawiki_section_links.py (file contents):
Revision 1173 by iritscen, Tue Jun 28 22:06:29 2022 UTC vs.
Revision 1176 by iritscen, Sun Sep 25 23:58:33 2022 UTC

# Line 69 | Line 69 | def scan_for_iw_links(page_text):
69          if not '#' in link_text:
70              #pywikibot.stdout('Link doesn\'t have a section anchor in it. Skipping.')
71              continue
72 +
73 +        # If this link has an interwiki prefix, it can be ignored
74 +        is_interwiki = False
75 +        if found_iw_match == False:
76 +            for prefix in interwiki_prefixes:
77 +                if prefix + ":" in link_text:
78 +                    #pywikibot.stdout('Skipping link {} because it is an interwiki link.'.format(link_text))
79 +                    is_interwiki = True
80 +                    break
81 +        if is_interwiki:
82 +            continue
83          
84          # If there is a '{' in the link, then probably it's a link built on transcluded text
85          # like "Quotes/Diary#{{C3}}", which we cannot expand and work with, so skip it
# Line 129 | Line 140 | def scan_for_iw_links(page_text):
140                      found_iw_match = True
141                      break
142          
132        # If we didn't match the prefix against any intrawiki prefixes, see if it matches
133        # against an interwiki prefix; if so, this link can be ignored
134        is_interwiki = False
135        if found_iw_match == False:
136            for prefix in interwiki_prefixes:
137                if prefix + ":" in link_text:
138                    #pywikibot.stdout('Skipping link {} because it is an interwiki link.'.format(link_text))
139                    is_interwiki = True
140                    break
141        if is_interwiki:
142            continue
143        
143          # If we still haven't turned this match into a URL, something's gone wrong
144          if (found_iw_match == False) or (iw_url == ""):
145              pywikibot.stdout('ERROR: Couldn\'t figure out link {}.'.format(link_text))

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)