Indic-TechCom/Tools/IndicBot/Scripts/template subs.py

From Meta, a Wikimedia project coordination wiki

Main page

Tools

Requests

Management

Indic Wikimedia Portal

Talk

template_subs.py is used to add or replace Template's parameter value from Excel sheet.

Excel Sheet Format[edit]

The Excel file should be in below format.

First Column:- It will contain the name of pages.
Second Column:- It will contain the name of the parameter which you want to add or change.
Third Column:- It will contain the value of the parameter.
Four Column:- It will contain the name of Templates (Ex. Infobox)

Wikipage Parameter Value Template
AA name Akash Infobox person
BB name Shivam Infobox person
CC mass 10,000 Kg Infobox rocket

Example[edit]

$ python3 bot.py template_subs
Password: 
Login success! Welcome, Jay!
Enter the Excel filename: Test.xlsx

Diff of Wikipage - AA
--- Before
+++ After
@@ -2 +2 @@
-|name = AMC
+|name = Akash
Do you want the chagnes (Yes - y, No - n, All - a, Quit- q)? a

Diff of Wikipage - BB
--- Before
+++ After
@@ -1 +1 @@
-{{Infobox |name = ABC |work = ABC |year = 1021 }}
+{{Infobox |name = Shivam |work = ABC |year = 1021 }}
BB - Changes Done!

Diff of Wikipage - CC
--- Before
+++ After
@@ -2 +2 @@
-|mass = 10 Kg
+|mass = 10,000 Kg
CC - Changes Done!

Done :)