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

Comparing ValBot/Python/check_interwiki_links.py (file contents):
Revision 1198 by iritscen, Sun Sep 21 21:50:56 2025 UTC vs.
Revision 1199 by iritscen, Mon Sep 29 18:15:05 2025 UTC

# Line 100 | Line 100 | def find_canonical_link(the_link):
100        canonical_name = canonical_name[:tag_end]
101        if len(canonical_name) > 100:
102           # Certain things can cause the trim to fail; report error and avoid slamming the output with massive page source from a failed trim
103 <         pywikibot.stdout('   ERROR: The {0} link "{1}" is a redirect to "{2}…" (string overflow).'.format(the_link.iw_prefix, the_link.page_slug, canonical_name[:100]))
103 >         pywikibot.stdout('   ERROR: The {0} link "{1}" is a redirect to "{2}..." (string overflow).'.format(the_link.iw_prefix, the_link.page_slug, canonical_name[:100]))
104           errors_issued = errors_issued + 1
105        else:
106           the_link.page_name = canonical_name.replace('_', ' ')
107           if '#' in the_link.page_slug:
108              the_link.page_name_only, _ = the_link.page_slug.split('#')
109 <            pywikibot.stdout('   The {0} link "{1}" is a redirect to "{2}", which is a valid page. Checking for section on that page….'.format(the_link.iw_prefix, the_link.page_name_only, the_link.page_name))
109 >            pywikibot.stdout('   The {0} link "{1}" is a redirect to "{2}", which is a valid page. Checking for section on that page....'.format(the_link.iw_prefix, the_link.page_name_only, the_link.page_name))
110              find_section(the_link, True)
111           else:
112              pywikibot.stdout('   The {0} link "{1}" is a redirect to "{2}", which is a valid page.'.format(the_link.iw_prefix, the_link.page_slug, the_link.page_name))
# Line 125 | Line 125 | def test_interwiki_link(the_link):
125        
126        # If linked page is in all caps, e.g. WP:BEANS, it's likely a deliberate use of a redirect
127        if the_link.page_slug.startswith('WP:') and the_link.page_slug == the_link.page_slug.upper():
128 <         pywikibot.stdout('   Got redirection code "{0}" for {1} link "{2}". This appears to be a deliberate use of a Wikipedia shortcut. Checking the target page….'.format(the_link.curl_response.history[0], the_link.iw_prefix, the_link.page_slug))
128 >         pywikibot.stdout('   Got redirection code "{0}" for {1} link "{2}". This appears to be a deliberate use of a Wikipedia shortcut. Checking the target page....'.format(the_link.curl_response.history[0], the_link.iw_prefix, the_link.page_slug))
129           find_canonical_link(the_link)
130        else:
131           permalink1 = 'Special:PermanentLink/'.lower()
132           permalink2 = 'Special:Permalink/'.lower()
133           page_slug_lower = the_link.page_slug.lower()
134           if page_slug_lower.startswith(permalink1) or page_slug_lower.startswith(permalink2):
135 <            pywikibot.stdout('   Got redirection code "{0}" for {1} permanent revision link "{2}". Checking the target page….'.format(the_link.curl_response.history[0], the_link.iw_prefix, the_link.page_slug))
135 >            pywikibot.stdout('   Got redirection code "{0}" for {1} permanent revision link "{2}". Checking the target page....'.format(the_link.curl_response.history[0], the_link.iw_prefix, the_link.page_slug))
136              find_canonical_link(the_link)
137           else:
138              pywikibot.stdout('   ERROR: Unrecognized type of redirection (code "{0}") for {1} link "{2}". You should check the link manually.'.format(the_link.curl_response.history[0], the_link.iw_prefix, the_link.page_slug))
# Line 147 | Line 147 | def test_interwiki_link(the_link):
147     elif 'Redirected from <a' in the_link.curl_response.text:
148        unintended_redirects_found = unintended_redirects_found + 1
149        possibly_print(the_link)
150 <      pywikibot.stdout('   WARNING: Got silently redirected by {0} link "{1}". Checking the target page….'.format(the_link.iw_prefix, the_link.page_slug))
150 >      pywikibot.stdout('   WARNING: Got silently redirected by {0} link "{1}". Checking the target page....'.format(the_link.iw_prefix, the_link.page_slug))
151        find_canonical_link(the_link) # calls find_section() at end
152     elif '#' in the_link.page_slug:
153        find_section(the_link, False)

Diff Legend

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