Difference between revisions of "Py-3rdparty-mediawiki"
Line 15: | Line 15: | ||
= wikipush / wikuser script = | = wikipush / wikuser script = | ||
+ | This script is in the scripts directory | ||
<source lang='bash'> | <source lang='bash'> | ||
#!/bin/bash | #!/bin/bash |
Revision as of 16:13, 3 November 2020
What is it
Extended functionality for
- pywikibot
- mwclient
Github
Installation
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki
./install
wikipush / wikuser script
This script is in the scripts directory
#!/bin/bash
# WF 2020-10-31
# wrapper for wikipush python
script=$(readlink -nf $BASH_SOURCE)
scriptname=$(basename $script)
scriptdir=$(dirname $script)
base=$scriptdir/..
export PYTHONPATH="${PYTHONPATH}:$base"
case $scriptname in
"wikipush")
python -m wikibot.wikipush "$@"
;;
"wikiuser")
python -m wikibot.wikiuser "$@"
;;
*)
echo "undefined script behavior: $scriptname"
;;
esac
WikiPush
WikiUser
Prerequisites
You might want to prepare some credential ini files with the Mediawiki-Japi CommandLine.
user-config.py
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:
# https://stackoverflow.com/a/60885381/1497139
# Slow down the robot such that it never makes a second page edit within
# 'put_throttle' seconds.
put_throttle = 0
The easiest way is to put it at $HOME/.pywikibot/user-config.py
Features
Encrypted credential handling
Py-3rdparty-mediawiki allows using pywikibot by simply giving each wiki an id and using the credential information created by MediaWiki-Japi. The needed family file is automatically created and registered. If you'd like to get a pure python solution for credential handling please file an issue on github - it's no big deal but i personally don't need it yet since i'm fine with the new CommandLine feature added recently.
Semantic MediaWiki API support
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1
Example
from wikibot.wikibot import WikiBot
wikibot=WikiBot.ofWikiId("test2")
wikibot.site ...