How to Use these Scripts
by iritscen@yahoo.com

In the course of maintaining the OniGalore wiki, I have written some Python and Bash shell scripts for Pywikibot.  My Bash shell scripts call Python scripts which are bundled with Pywikibot.  My Python scripts utilize the Pywikibot API to perform new tasks not covered by the bundled scripts.  To run the scripts, first install Pywikibot, then read below for an introduction to each file in the ValBot/ directory.

Bash/
drive_https_upgrade.sh
This script was designed to take a TXT report from a Validate External Links session run without the --show-https-upgrades argument and use it to mass-change all the URLs for sites that wanted an upgrade from HTTP to HTTPS.  In such a TXT report, links which wanted an HTTPS upgrade would have the phrase "Skipping URL x because I have not been asked to show http->https upgrades" in it, so the script uses regex to search for "http->https".  It edits all such links from the one numbered FIX_START to the one numbered FIX_END.  This script served its purpose and probably won't be needed again, but it has value as a tutorial.

drive_slash_adding.sh
This script was designed to take a TXT report from a Validate External Links session run without the --show-added-slashes argument and use it to mass-change all the URLs that wanted a trailing slash added to them.  In such a TXT report, URLs where the server asked for a trailing '/' to be added to the URL would have the phrase "Skipping URL x because I have not been asked to show added trailing slashes", so the script searches for the word "trailing".  This script served its purpose and probably won't be needed again, but it has value as a tutorial.

Docs/
Generator and replace options.txt
This is the help text generated by "python pwb.py replace -help".  It shows the many options you have for using the built-in replace.py script and for asking any built-in Pywikibot script to limit its scope to certain pages.

Pywikibot commands.rtf
General advice on how to use Pywikibot properly.

Read-me.rtf
You are here.

Python/
In Terminal, 'cd' into the core/ directory and run the command "python pwb.py /path/to/script [arguments for script]".  If you were running a built-in Pywikibot script, you could simply invoke it with "python pwb.py [name of script without suffix] [arguments]", but since these scripts that you downloaded are outside the core/ directory they need full pathname qualification.

check_interwiki_links.py
This script scans the wiki markup of a given page, or all the pages in a given category, for interwiki links such as [[wp:Example]] and [[wikt:definition|some word]].  It then tests those links to make sure they're valid and prints an "ERROR:" message if the page is not found or if the interwiki link specified a section on that page (e.g. [[wp:Article#References]]) and that section cannot be found.

Usage:
python pwb.py path/to/check_interwiki_links.py -page:"Daodan"
python pwb.py path/to/check_interwiki_links.py -cat:"Wiki Support" 
Adding the argument "-dbg" will print the name of each page as it is being scanned instead of only the pages with bad links.

check_intrawiki_section_links.py
This script scans the wiki markup of a given page, or all the pages in a given category, for intrawiki links that have section links in them such as [[Konoko#In-game appearance]].  It then looks for those sections on the relevant pages and prints an "ERROR:" message if a problem is encountered.  "ADVICE:" messages are printed when a link cannot be tested because transclusion is being used to build the link in a way that the script cannot unravel.

Usage: The syntax is the same as for check_interwiki_links.py.  Adding the argument "-dbg" will print the name of each page as it is being scanned as well as verbose logic explaining how each link is being processed.

find_external_images.py
This script scrapes the HTML markup of a given page, or all the pages in a given category, and alerts you to externally-linked images so you can consider uploading them to the wiki.  A division is made between images hosted on oni2.net and hosted outside the domain.  The script can be asked to show embedded (inline) images and/or images which are externally linked (presented as clickable links).

Usage:
python pwb.py path/to/find_external_images.py -linked -page:"Press coverage"
python pwb.py path/to/find_external_images.py -embedded -page:"State of Emergency"
python pwb.py path/to/find_external_images.py -linked -embedded -cat:"Category:Real World"
Adding the argument "-dbg" will print the name of each page as it is being scanned instead of only the pages with bad links.

uncapitalize_image_suffixes.py
This script checks all the images on the wiki for capitalized file suffixes (.JPG instead of .jpg, etc.) and renames (i.e., moves) them to non-capitalized versions.  Note that any pages linking to the images will need to be corrected manually afterward, but the script will tell you which pages link to each image that it renames.

Usage: Simply invoke the script with no arguments.