| 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)) |
| 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)) |
| 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) |