How to set up pywikibot

As part of managing a wiki, sometimes you need bulk action tools. The mediawiki tool for this is called pywikibot. This is how I set it up:

python -m venv .pyb
# activate the venv
python -m pip install pywikibot

This makes the command pwb available to use. We now have to teach it where the wiki is and what account to use. For this, we create a bot account on the wiki using the UI. Then, we come back and run this:

pwb generate_family_file
pwb generate_user_files

As part of the user files command, give it the name of the bot created. Do not give any password. The password must be entered as part of the next command:

pwb login

At this point, there should be a scripts directory in the current working directory. However, the inbuilt scripts refuse to run because it can't find its i18n configuration. There are a couple of ways to grab it. One is to git clone it inside the scripts directory, as recommended here. However, before you can do so, you have to temporarily stash the existing scripts/i18n directory somewhere, otherwise git gets confused. The other way is to grab the directories from inside venv, like so: .\.pyw\Lib\site-packages\pywikibot\scripts\i18n. So copy the directories for i18n for the scripts you're interested in, and put it in the scripts/i18n directory.

Now we can run the commands, like so

pwb scripts/pagefromfile -notitle -file:dict.txt

Here is a puzzle page for the puzzle "Eclipse" from The Talos Wiki: In the Beginning created by pywikibot.

Comments

Popular posts from this blog

Laptop Surprises: Lenovo Yoga Slim 7i

Setting coordinates in Phaser where the body and the sprite are offset from each other

Windows Task Manager is lying to you, and I don't know how to make it stop