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 1171 by iritscen, Mon Mar 21 21:23:25 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 82 | Line 93 | def scan_for_iw_links(page_text):
93          # we're out of luck.
94          if link_text.startswith('/'):
95              link_text = page_name + link_text
96 <            pywikibot.stdout('Changed link_text to {} on account of "/".'.format(link_text))
96 >            #pywikibot.stdout('Changed link_text to {} on account of "/".'.format(link_text))
97          
98          # If this is a relative "../" link, find the parent page and set ourselves to that page,
99          # then remove the relative portion of the link. Note that this is only performed once,
# 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 {}. Aborting script.'.format(link_text))
146 <            quit()
145 >            pywikibot.stdout('ERROR: Couldn\'t figure out link {}.'.format(link_text))
146 >            continue
147  
148          # Test the URL
149          iw_url = iw_url.replace(' ', '_')

Diff Legend

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