| 14 |
|
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 {\field{\*\fldinst{HYPERLINK "https://www.mediawiki.org/wiki/Manual:Pywikibot/Installation"}}{\fldrslt install Pywikibot}}, then read below.\ |
| 15 |
|
\ |
| 16 |
|
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0 |
| 17 |
< |
\cf0 \ul \ulc0 Python\ulnone \ |
| 17 |
> |
\cf0 \ul \ulc0 Python/\ulnone \ |
| 18 |
|
In Terminal, 'cd' into the core/ directory and run the command "python pwb.py /path/to/script [arguments for script]". When running a built-in Pywikibot script, you would simply invoke it with "python pwb.py [name of script without suffix] [arguments]", but since these scripts are outside the core/ directory they need full pathname qualification.\ |
| 19 |
|
\ |
| 20 |
|
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0 |
| 24 |
|
This script scans 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 (1) the page is not found, (2) a redirect is encountered, or (3) the page exists but the specified section cannot be found.\ |
| 25 |
|
\ |
| 26 |
|
Usage:\ |
| 27 |
< |
python pwb.py check_interwiki_links -page:"Daodan"\ |
| 28 |
< |
python pwb.py check_interwiki_links -cat:"Wiki Support" \ |
| 27 |
> |
python pwb.py path/to/check_interwiki_links.py -page:"Daodan"\ |
| 28 |
> |
python pwb.py path/to/check_interwiki_links.py -cat:"Wiki Support" \ |
| 29 |
|
\ |
| 30 |
|
|
| 31 |
|
\f0\b check_intrawiki_section_links.py |
| 37 |
|
|
| 38 |
|
\f0\b find_external_images.py |
| 39 |
|
\f1\b0 \ |
| 40 |
< |
This script scrapes the HTML of the supplied category's pages and alerts you to externally-linked images so you can consider uploading them to the wiki. Special attention is drawn to images hosted elsewhere on oni2.net. This script isn't totally finished and the argument-handling code is in a bit of disarray, but it should support showing inline and/or non-embedded external image links.\ |
| 40 |
> |
This script scrapes the HTML of the supplied category's pages and alerts you to externally-linked images so you can consider uploading them to the wiki. Special attention is drawn to images hosted elsewhere on oni2.net. The script can be asked to show inline (embedded) images and/or images which are externally linked.\ |
| 41 |
|
\ |
| 42 |
|
Usage:\ |
| 43 |
< |
python pwb.py find_external_images -page:"State of Emergency"\ |
| 44 |
< |
python pwb.py find_external_images -justshown -cat:"Category:Real World"\ |
| 43 |
> |
python pwb.py path/to/find_external_images.py -inlined -page:"State of Emergency"\ |
| 44 |
> |
python pwb.py path/to/find_external_images.py -linked -inlined -cat:"Category:Real World"\ |
| 45 |
|
\ |
| 46 |
|
|
| 47 |
|
\f0\b uncapitalize_image_suffixes.py |
| 48 |
|
\f1\b0 \ |
| 49 |
|
This script checks all the images on the wiki for capitalized file suffixes (.JPG instead of .jpg, etc.) and renames them to be non-capitalized. 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 or embed each image that it renames.\ |
| 50 |
|
\ |
| 51 |
+ |
Usage: python pwb.py path/to/uncapitalize_image_suffixes.py\ |
| 52 |
+ |
\ |
| 53 |
|
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0 |
| 54 |
< |
\cf0 \ul \ulc0 Bash\ulnone \ |
| 54 |
> |
\cf0 \ul Bash/\ulnone \ |
| 55 |
|
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0 |
| 56 |
|
|
| 57 |
|
\f0\b \cf0 drive_https_upgrade.sh |
| 68 |
|
\f1\i0 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.\ |
| 69 |
|
\ |
| 70 |
|
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0 |
| 71 |
< |
\cf0 \ul \ulc0 Docs\ |
| 71 |
> |
\cf0 \ul Docs/\ |
| 72 |
|
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0 |
| 73 |
|
|
| 74 |
|
\f0\b \cf0 \ulnone Generator and replace options.txt |