Difference between revisions of "Py-3rdparty-mediawiki"
Line 88: | Line 88: | ||
= WikiUser = | = WikiUser = | ||
+ | <source lang='bash'> | ||
+ | wikiuser -h | ||
+ | usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL] | ||
+ | [-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION] | ||
+ | [-w WIKIID] [-y] | ||
+ | |||
+ | WikiUser credential handling | ||
+ | |||
+ | Created by Wolfgang Fahl on 2020-10-31. | ||
+ | Copyright 2020 Wolfgang Fahl. All rights reserved. | ||
+ | |||
+ | Licensed under the Apache License 2.0 | ||
+ | http://www.apache.org/licenses/LICENSE-2.0 | ||
+ | |||
+ | Distributed on an "AS IS" basis without warranties | ||
+ | or conditions of any kind, either express or implied. | ||
+ | |||
+ | USAGE | ||
+ | |||
+ | optional arguments: | ||
+ | -h, --help show this help message and exit | ||
+ | -d, --debug set debug level [default: None] | ||
+ | -V, --version show program's version number and exit | ||
+ | -e EMAIL, --email EMAIL | ||
+ | email of the user | ||
+ | -f FILEPATH, --file FILEPATH | ||
+ | ini-file path | ||
+ | -l URL, --url URL url of the wiki | ||
+ | -s SCRIPTPATH, --scriptPath SCRIPTPATH | ||
+ | script path | ||
+ | -p PASSWORD, --password PASSWORD | ||
+ | password | ||
+ | -u USER, --user USER os user id | ||
+ | -v VERSION, --wikiVersion VERSION | ||
+ | version of the wiki | ||
+ | -w WIKIID, --wikiId WIKIID | ||
+ | wiki Id | ||
+ | -y, --yes immediately store without asking | ||
+ | </source> | ||
= Prerequisites = | = Prerequisites = |
Revision as of 16:17, 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. It should be linked with two names
ln wikipush wikiuser
and be added to your path e.g by doing a symbolic link
cd $HOME/bin
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .
#!/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
usage
wikipush -h
family and mylang are not set.
Defaulting to family='test' and mylang='test'.
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t
TARGET [-p PAGES [PAGES ...]]
Created on 2020-10-29
Created by Wolfgang Fahl on 2020-10-31.
Copyright 2020 Wolfgang Fahl. All rights reserved.
Licensed under the Apache License 2.0
http://www.apache.org/licenses/LICENSE-2.0
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-d, --debug set debug level [default: None]
-V, --version show program's version number and exit
-l, --login login to source wiki for access permission
-f, --force force to overwrite existing pages
-i, --ignore ignore upload warnings e.g. duplicate images
-q QUERY, --query QUERY
select pages with given SMW ask query
-s SOURCE, --source SOURCE
source wiki id
-t TARGET, --target TARGET
target wiki id
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]
list of page Titles to be pushed
WikiUser
wikiuser -h
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]
[-w WIKIID] [-y]
WikiUser credential handling
Created by Wolfgang Fahl on 2020-10-31.
Copyright 2020 Wolfgang Fahl. All rights reserved.
Licensed under the Apache License 2.0
http://www.apache.org/licenses/LICENSE-2.0
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
optional arguments:
-h, --help show this help message and exit
-d, --debug set debug level [default: None]
-V, --version show program's version number and exit
-e EMAIL, --email EMAIL
email of the user
-f FILEPATH, --file FILEPATH
ini-file path
-l URL, --url URL url of the wiki
-s SCRIPTPATH, --scriptPath SCRIPTPATH
script path
-p PASSWORD, --password PASSWORD
password
-u USER, --user USER os user id
-v VERSION, --wikiVersion VERSION
version of the wiki
-w WIKIID, --wikiId WIKIID
wiki Id
-y, --yes immediately store without asking
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 ...