Task #3
Bot24 Task
Renames Mexican TV station callsign redirects.
Operator(s)Negative24
Scriptrename_redirect.py
Script AuthorNegative24
TypeSupervised (manual start; one-off batches)
Programming language(s)Pywikibot

Description

edit

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

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

Consensus

edit

Support

edit
  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 (tc) 04:36, 10 December 2015 (UTC)

Oppose

edit

Tests

edit

Test 1

edit

Date: 03:47, 10 December 2015 (UTC)
Site: 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

edit

The old redirect, testwiki:Ausdrücklich, has been created and pointed to testwiki: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

edit

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

Run
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:

# -*- coding: utf-8 -*-
(u"Ausdrücklich", u"Äußerung")

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 @@
- # {{#explode: n/92/120525|/|1}} [[Ausdrücklich#Test Section]] generates: {{#explode: n/92/120525|/|1}}
+ # {{#explode: n/92/120525|/|1}} [[Äußerung#Test Section]] generates: {{#explode: n/92/120525|/|1}}

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 [[Ausdrücklich|This is a label]] April de 2015 até às <section begin="fim do prazo"/>20:57 '''UTC''' de 4 de May de 2015<section end="fim do prazo"/>
+ ;Prazo de votação (30 dias): das 20:57 '''UTC''' de 4 de [[Äußerung|This is a label]] April de 2015 até às <section begin="fim do prazo"/>20:57 '''UTC''' de 4 de May de 2015<section end="fim do prazo"/>

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ücklich#Section Test]]linktrail 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ßerung#Section Test]]linktrail 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

edit

Bot actions:

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

Bot edits: 4

Conclusion

edit

All objectives met. No malfunctions or errors reported.

Test 2

edit

Date: 04:56, 13 December 2015 (UTC)
Site: 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

edit

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

Action

edit

testwiki:Redirect 1 and testwiki:Redirect 2 will be moved to testwiki:New Redirect 1 and testwiki:Redirect 2.

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

Contents of redirects.py:

# -*- coding: utf-8 -*-
(u"Redirect 1", u"New Redirect 1")
(u"Redirect 2", u"New Redirect 2")

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

edit

Bot actions:

Bot edits: 4

Conclusion

edit

All objectives met. No malfunctions or errors reported.