User:Bot24/Tasks/Task 3

Description
Script renames a batch of redirects specified in a Python file with tuples corresponding to original (currently existing) redirects and new redirects. Script then makes sure the new redirect points to the target the old redirect pointed to. It then finds all references to the old redirect, finds the links, and then if the link points to the old redirect, it modifies the link to point to the new redirect, keeping the original section, label, and any other arguments (it only targets the title to begin with).

Operation Actions

 * 1) FOR every old redirect in list of old redirects to new redirects:
 * 2) IF old redirect doesn't exist, BREAK to next old redirect
 * 3) IF new redirect doesn't exist, create it and point to final destination
 * 4) Create a list of pages linking to old redirect to process; FOR every page in list of pages to process:
 * 5) FOR every link on page:
 * 6) IF link points to old redirect, modify the title to point to the new redirect

Support

 * 1) Support I commissioned this as a bot to simplify one of the most daunting tasks I've faced in my 10 years as an editor: the need to move hundreds of redirects as Mexico's analog-digital transition hits peak form. Since I began editing Mexico TV articles on a large scale in 2014, Mexico's digital transition has advanced extremely rapidly, which last year led to the beginning of the rewrite of the 32 state lists, and this year to many additions of new digital television technical information. I had to spend time doing the small batches of stations that were done earlier this year. It was quite a task just to do 10 or 12 of them, let alone the hundreds that will be changing over in the next month. With the DTV transition and analog shutoff occurring primarily this month, the use of a bot to complete the task will automate a lot of manual labor (hundreds of TV stations are affected, most of them redirects in Wikipedia) and ensure that my time can go to updating the separate articles that exist and improving coverage of Mexican broadcasting on en.wiki. Raymie (t • c) 04:36, 10 December 2015 (UTC)

Test 1
Date: 03:47, 10 December 2015 (UTC)

Site: [//test.wikipedia.org/ Test Wikipedia]

Machine: Tool Labs

Commit: 75a9513781ab11c660522642c73b074abaa4938e

Simulated? No

Objectives:
 * 1) Demonstrate scripts capability to modify a new redirect correctly
 * 2) Demonstrate scripts capability to change links from old redirect to new redirect correctly
 * 3) Demonstrate scripts capability to work on pages with special characters

Scenario
The old redirect, Ausdrücklich, has been created and pointed to Robert Domes (diff). Many pages have been modified to contain different types of links (some with sections, labels, and linktrails) to the old redirect; some of these pages have special characters in their text and titles (diff 1 2 3).

Action
The old redirect will be renamed to Äußerung.

Command: python scripts/rename_redirect.py -family:test -lang:test -redirectfile:../test1.py -summary:"Bot24 Task #3, Test #1: Bot Action! Renaming redirect"

Contents of test1.py: (u"Ausdrücklich", u"Äußerung")
 * 1) -*- coding: utf-8 -*-

Output: Summary: Bot24 Task #3, Test #1: Bot Action! Renaming redirect Moving Ausdrücklich to Äußerung. Ausdrücklich was found. Proceeding... Target: Robert Domes Äußerung doesn't exist. Creating it now... @@ -0,0 +1 @@ + #REDIRECT Robert Domes

Sleeping for 9.4 seconds, 2015-12-10 03:33:32 Page Äußerung saved Working on: Anton Sterbling @@ -17 +17 @@ - # Ausdrücklich generates: + # Äußerung generates:

Sleeping for 9.1 seconds, 2015-12-10 03:33:43 Page Anton Sterbling saved WARNING: /data/project/bot24/bot24/env/local/lib/python2.7/site-packages/pywikibot/family.py:931: FamilyMaintenanceWarning: Family name wikimediachapter does not match family module name wikimedia Working on: Wikipédia:Escolha do artigo em destaque/Teste @@ -13 +13 @@ - ;Prazo de votação (30 dias): das 20:57 UTC de 4 de This is a label April de 2015 até às 20:57 UTC de 4 de May de 2015 + ;Prazo de votação (30 dias): das 20:57 UTC de 4 de This is a label April de 2015 até às 20:57 UTC de 4 de May de 2015

Sleeping for 8.7 seconds, 2015-12-10 03:33:53 Page Wikipédia:Escolha do artigo em destaque/Teste saved Working on: 21 Ocak @@ -37 +37 @@ - * 2001 - Filipinler'de Devlet Başkan Yardımcısı Gloria Arroyo, sokağın Ausdrücklichlinktrail ve ordunun baskısıyla Joseph Estrada'nın yerine Devlet Başkanı oldu. + * 2001 - Filipinler'de Devlet Başkan Yardımcısı Gloria Arroyo, sokağın Äußerunglinktrail ve ordunun baskısıyla Joseph Estrada'nın yerine Devlet Başkanı oldu.

Sleeping for 9.5 seconds, 2015-12-10 03:34:02 Page 21 Ocak saved

Results
Bot actions:
 * The new redirect, Äußerung, was created and was pointed to the correct target (diff)
 * All links pointing to the old redirect were changed correctly to point to the new redirect (diff 1 2 3)

Bot edits: 4

Conclusion
All objectives met. No malfunctions or errors reported.

Test 2
Date: 04:56, 13 December 2015 (UTC)

Site: [//test.wikipedia.org/ Test Wikipedia]

Machine: Local machine

Commit: ded72963bd9eb853ec458d58739b782321d9213a

Simulated? No

Objectives:
 * 1) Demonstrate that script doesn't save each page with fixed links after every redirect (bundles edits and submits at the end)

Scenario
List of Redirects has been created with 2 redirects that will be moved (diff).

Action
Redirect 1 and Redirect 2 will be moved to New Redirect 1 and Redirect 2.

Command: python scripts/rename_redirect.py -family:test -lang:test -redirectfile:../redirects.py -summary:"Bot24 Test #2. Bot Action"

Contents of redirects.py: (u"Redirect 1", u"New Redirect 1") (u"Redirect 2", u"New Redirect 2")
 * 1) -*- coding: utf-8 -*-

Output: Moving Redirect 1 to New Redirect 1. Redirect 1 was found. Proceeding... Target: Page759 New Redirect 1 doesn't exist. Creating it now... @@ -0,0 +1 @@ + #REDIRECT Page759 Sleeping for 8.6 seconds, 2015-12-13 04:45:01 Page New Redirect 1 saved Working on: Page 982 Working on: List of Redirects Moving Redirect 2 to New Redirect 2. Redirect 2 was found. Proceeding... Target: Test Felix New Redirect 2 doesn't exist. Creating it now... @@ -0,0 +1 @@ + #REDIRECT Test Felix Sleeping for 7.7 seconds, 2015-12-13 04:45:12 Page New Redirect 2 saved Working on: List of Redirects @@ -2,2 +2,2 @@ - * Redirect 1 + * New Redirect 1 - * Redirect 2 + * New Redirect 2 Sleeping for 8.5 seconds, 2015-12-13 04:45:22 Page List of Redirects saved @@ -1 +1 @@ - This is a test page that links to a redirect. See, right here: Redirect 1. This is just a test. Thank you. + This is a test page that links to a redirect. See, right here: New Redirect 1. This is just a test. Thank you. Sleeping for 9.1 seconds, 2015-12-13 04:45:31 Page Page 982 saved

Results
Bot actions:
 * New Redirect 1 and New Redirect 2 were created (diff 1 2)
 * List of Redirects was edited once with all the links fixed for Redirect 1 and Redirect 2 (diff)
 * Page 982 was edited to fix a Redirect 1 link (diff)

Bot edits: 4

Conclusion
All objectives met. No malfunctions or errors reported.