http://mediawiki-japi.bitplan.com/api.php?action=feedcontributions&user=Wf&feedformat=atomBITPlan mediawiki-japi Wiki - User contributions [en]2024-03-29T09:17:38ZUser contributionsMediaWiki 1.35.5http://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1247Py-3rdparty-mediawiki2021-11-09T08:17:36Z<p>Wf: /* WikiPush */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# [https://www.mediawiki.org/wiki/Manual:Pywikibot/de pywikibot]<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
== via pip ==<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki<br />
# alternatively if your pip is not a python3 pip<br />
pip3 install py-3rdparty-mediawiki<br />
</source><br />
=== upgrade ===<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki -U<br />
# alternatively if your pip is not a python3 pip<br />
pip3 install py-3rdparty-mediawiki -U<br />
</source><br />
<br />
== Via Source code ==<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikibackup / wikiedit / wiknuke / wikirestore/ wikiquery / wikiupload / wikiuser scripts =<br />
== Setup method ==<br />
If you installed with the method above console_script will have been added to your environment. You can e.g. check<br />
<source lang='bash' highlight='1'><br />
which wikipush<br />
/Users/wf/Library/Python/3.8/bin/wikipush<br />
</source><br />
and there should be a wikipush script in your path.<br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above. This approach is deprecated and therefore incomplete as of 2020-12<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash' highlight='1'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
= wikiquery =<br />
wikiquery allows to send SMW ask-query via commandline and get the results in json or csv format. With the query division parameter the limits of SMW for the maximum amount of displayed<br />
results can be overcome. E.g. if you set<br />
<pre><br />
$smwgQMaxInlineLimit=1500;<br />
$smwgQMaxInlineLimitSets=1500;<br />
$smwgQMaxLimit = 5000;<br />
</pre><br />
You'll be able to get more than 1500/5000 results. <br />
== usage ==<br />
<source lang='bash' highlight='1'><br />
wikiquery -h<br />
usage: wikiquery [-h] [-d] [-V] [-l] -s SOURCE [--format FORMAT]<br />
[--entityName ENTITYNAME] [--limit LIMIT] [--progress]<br />
[-q QUERY] [--queryFile QUERYFILE] [-qf QUERYFIELD]<br />
[-p PAGES [PAGES ...]] [-ui] [-qd QUERYDIVISION]<br />
<br />
wikipush<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: False]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
--format FORMAT format to use for query result csv,json,xml,ttl or<br />
wiki<br />
--entityName ENTITYNAME<br />
name of the entites that are queried - only needed for<br />
some output formats - default is 'data'<br />
--limit LIMIT limit for query<br />
--progress shows progress for query<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
--queryFile QUERYFILE<br />
file the query should be read from<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
-ui, --withGUI Pop up GUI for selection<br />
-qd QUERYDIVISION, --queryDivision QUERYDIVISION<br />
divide query into equidistant subintervals to limit<br />
the result size of the individual queries<br />
</source><br />
== Examples ==<br />
=== query1.ask ===<br />
<source lang='bash'><br />
{{#ask: [[IsA::Event]][[Acronym::~ES*]][[start date::>2018]][[start date::<2019]] <br />
| mainlabel=pageTitle<br />
| ?Title = title <br />
| ?Event in series = series <br />
| ?ordinal=ordinal <br />
| ?Homepage = homepage <br />
| format=table <br />
}}<br />
</source><br />
<br />
=== csv ===<br />
<source lang='bash' highlight='1'><br />
wikiquery -s or --queryFile query1.ask --format csv<br />
pageTitle;title;series;ordinal;homepage<br />
ESA 2018;26th Annual European Symposium on Algorithms;ESA;None;http://algo2018.hiit.fi/esa/<br />
ESEC/FSE 2018;26th ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering (ESEC/FSE);ESEC/FSE;None;https://2018.fseconference.org/<br />
ESOP 2018;27th European Symposium on Programming;ESOP;None;https://etaps.org/2018/esop<br />
ESORICS 2018;23rd European Symposium on Research in Computer Security,;ESORICS;None;None<br />
ESSCIRC 2018;44th European Solid-State Circuits Conference;ESSCIRC;None;None<br />
ESWC 2018;15th European Semantic Web Symposium (ESWS);ESWC;None;http://2018.eswc-conferences.org/<br />
</source><br />
<br />
=== json ===<br />
<source lang='bash'><br />
wikiquery -s or --queryFile query1.ask --format json<br />
</source><br />
<source lang='json'><br />
{<br />
"data": [<br />
{<br />
"pageTitle": "ESA 2018",<br />
"title": "26th Annual European Symposium on Algorithms",<br />
"series": "ESA",<br />
"ordinal": null,<br />
"homepage": "http://algo2018.hiit.fi/esa/"<br />
},<br />
{<br />
"pageTitle": "ESEC/FSE 2018",<br />
"title": "26th ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering (ESEC/FSE)",<br />
"series": "ESEC/FSE",<br />
"ordinal": null,<br />
"homepage": "https://2018.fseconference.org/"<br />
},<br />
{<br />
"pageTitle": "ESOP 2018",<br />
"title": "27th European Symposium on Programming",<br />
"series": "ESOP",<br />
"ordinal": null,<br />
"homepage": "https://etaps.org/2018/esop"<br />
},<br />
{<br />
"pageTitle": "ESORICS 2018",<br />
"title": "23rd European Symposium on Research in Computer Security,",<br />
"series": "ESORICS",<br />
"ordinal": null,<br />
"homepage": null<br />
},<br />
{<br />
"pageTitle": "ESSCIRC 2018",<br />
"title": "44th European Solid-State Circuits Conference",<br />
"series": "ESSCIRC",<br />
"ordinal": null,<br />
"homepage": null<br />
},<br />
{<br />
"pageTitle": "ESWC 2018",<br />
"title": "15th European Semantic Web Symposium (ESWS)",<br />
"series": "ESWC",<br />
"ordinal": null,<br />
"homepage": "http://2018.eswc-conferences.org/"<br />
}<br />
]<br />
}<br />
</source><br />
<br />
= wikibackup =<br />
== usage ==<br />
<source lang='bash'><br />
wikibackup -h<br />
usage: wikibackup [-h] [-d] [-V] [-g] [-l] -s SOURCE [-wi]<br />
[--backupPath BACKUPPATH] [--limit LIMIT] [--progress]<br />
[-q QUERY] [--queryFile QUERYFILE] [-qf QUERYFIELD]<br />
[-p PAGES [PAGES ...]] [-ui] [-qd QUERYDIVISION]<br />
<br />
wikipush<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: False]<br />
-V, --version show program's version number and exit<br />
-g, --git use git for version control<br />
-l, --login login to source wiki for access permission<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-wi, --withImages copy images on the given pages<br />
--backupPath BACKUPPATH<br />
path where the backup should be stored<br />
--limit LIMIT limit for query<br />
--progress shows progress for query<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
--queryFile QUERYFILE<br />
file the query should be read from<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
-ui, --withGUI Pop up GUI for selection<br />
-qd QUERYDIVISION, --queryDivision QUERYDIVISION<br />
divide query into equidistant subintervals to limit<br />
the result size of the individual queries<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3<br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"<br />
editing 1 pages in test (dry run)<br />
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍 |isA=CFP<br />
-|Acronym=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
-|Title=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Acronym=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Title=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
|Start date=2010/11/01<br />
}}<br />
-CALL FOR PAPER<br />
+CFP<br />
Journal: Advances in Multimedia - An International Journal (AMIJ)<br />
</source><br />
<br />
= wikirestore =<br />
Tool to restore wiki pages from an local backup, created with wikibackup, to an destination wiki.<br />
<br />
== Arguments ==<br />
{| class="wikitable"<br />
|-<br />
!| Argument <br />
!| Description<br />
|-<br />
| -s<br />
| Source wiki - Only used to query page names. The queried page names will then be looked up in the backup.<br />
|-<br />
| -t<br />
| Target wiki - The backup is restored in this wiki<br />
|-<br />
| -q<br />
| SMW query to select the pages to be restored. Note that the query is only used to select the page names the actual backup is then restored from the local backup.<br />
|-<br />
| -p<br />
| Names of the pages to be restored<br />
|-<br />
| --backupPath<br />
| define location of the backup. Default is the default backup location of the target wiki.<br />
|-<br />
<br />
|}<br />
If argument '''-s''' is used a page query is executed therefore all arguments related to an page query can be used such as '''-ui''' and '''--limit'''.<br />
<br />
== Examples ==<br />
=== --backupPath ===<br />
Use this argument to define a different backup folder<br />
====wikibackup====<br />
<syntaxhighlight lang="shell" line='line'><br />
$ wikibackup -s orth --backupPath "/home/user/wikibackup/orth_copy" -q "[[isA::Event]]" --limit 10<br />
<br />
downloading 10 pages from orth to /home/user/wikibackup/orth_copy<br />
1/10 ( 10%): downloading " DBKDA 2021" ...✅<br />
2/10 ( 20%): downloading "ENERGY 2021" ...✅<br />
3/10 ( 30%): downloading "ICAS 2021" ...✅<br />
4/10 ( 40%): downloading "ICNS 2021" ...✅<br />
5/10 ( 50%): downloading 2021 ICIMP ...✅<br />
6/10 ( 60%): downloading 3DUI 2020 ...✅<br />
7/10 ( 70%): downloading 3IA 2009 ...✅<br />
8/10 ( 80%): downloading 3PGIC 2010 ...✅<br />
9/10 ( 90%): downloading 4S4D 2017 ...✅<br />
10/10 ( 100%): downloading 5GU 2017 ...✅<br />
</syntaxhighlight><br />
<br />
====wikirestore====<br />
<syntaxhighlight lang="shell"><br />
$ wikirestore -t orth --backupPath "/home/user/wikibackup/orth_copy"<br />
<br />
restoring 10 pages from /home/user/wikibackup/orth_copy to orth<br />
1/10 ( 10%): restore 2021 ICIMP ...✅<br />
2/10 ( 20%): restore "ICNS 2021" ...✅<br />
3/10 ( 30%): restore 3PGIC 2010 ...✅<br />
4/10 ( 40%): restore 4S4D 2017 ...✅<br />
5/10 ( 50%): restore "ENERGY 2021" ...✅<br />
6/10 ( 60%): restore 3DUI 2020 ...✅<br />
7/10 ( 70%): restore " DBKDA 2021" ...✅<br />
8/10 ( 80%): restore 3IA 2009 ...✅<br />
9/10 ( 90%): restore "ICAS 2021" ...✅<br />
10/10 ( 100%): restore 5GU 2017 ...✅<br />
</syntaxhighlight><br />
<br />
=== Scenario: Restore triangle ===<br />
<syntaxhighlight lang="shell"><br />
$ wikirestore -s or -q "[[isA:Event]]" -t orth --backupPath "/home/user/wikibackup/orth_copy"<br />
</syntaxhighlight><br />
With this command we query all page names that are an Event from the wiki '''or''' and restore them in the wiki '''orth''' with the version of the page that is stored in '''/home/user/wikibackup/orth_copy'''.<br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highlight='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1246Py-3rdparty-mediawiki2021-07-16T09:58:20Z<p>Wf: /* usage */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# [https://www.mediawiki.org/wiki/Manual:Pywikibot/de pywikibot]<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
== via pip ==<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki<br />
# alternatively if your pip is not a python3 pip<br />
pip3 install py-3rdparty-mediawiki<br />
</source><br />
=== upgrade ===<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki -U<br />
# alternatively if your pip is not a python3 pip<br />
pip3 install py-3rdparty-mediawiki -U<br />
</source><br />
<br />
== Via Source code ==<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikibackup / wikiedit / wiknuke / wikirestore/ wikiquery / wikiupload / wikiuser scripts =<br />
== Setup method ==<br />
If you installed with the method above console_script will have been added to your environment. You can e.g. check<br />
<source lang='bash' highlight='1'><br />
which wikipush<br />
/Users/wf/Library/Python/3.8/bin/wikipush<br />
</source><br />
and there should be a wikipush script in your path.<br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above. This approach is deprecated and therefore incomplete as of 2020-12<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash' highlight='1'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= wikibackup =<br />
== usage ==<br />
<source lang='bash'><br />
wikibackup -h<br />
usage: wikibackup [-h] [-d] [-V] [-g] [-l] -s SOURCE [-wi]<br />
[--backupPath BACKUPPATH] [--limit LIMIT] [--progress]<br />
[-q QUERY] [--queryFile QUERYFILE] [-qf QUERYFIELD]<br />
[-p PAGES [PAGES ...]] [-ui] [-qd QUERYDIVISION]<br />
<br />
wikipush<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: False]<br />
-V, --version show program's version number and exit<br />
-g, --git use git for version control<br />
-l, --login login to source wiki for access permission<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-wi, --withImages copy images on the given pages<br />
--backupPath BACKUPPATH<br />
path where the backup should be stored<br />
--limit LIMIT limit for query<br />
--progress shows progress for query<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
--queryFile QUERYFILE<br />
file the query should be read from<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
-ui, --withGUI Pop up GUI for selection<br />
-qd QUERYDIVISION, --queryDivision QUERYDIVISION<br />
divide query into equidistant subintervals to limit<br />
the result size of the individual queries<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3<br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"<br />
editing 1 pages in test (dry run)<br />
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍 |isA=CFP<br />
-|Acronym=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
-|Title=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Acronym=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Title=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
|Start date=2010/11/01<br />
}}<br />
-CALL FOR PAPER<br />
+CFP<br />
Journal: Advances in Multimedia - An International Journal (AMIJ)<br />
</source><br />
<br />
= wikirestore =<br />
Tool to restore wiki pages from an local backup, created with wikibackup, to an destination wiki.<br />
<br />
== Arguments ==<br />
{| class="wikitable"<br />
|-<br />
!| Argument <br />
!| Description<br />
|-<br />
| -s<br />
| Source wiki - Only used to query page names. The queried page names will then be looked up in the backup.<br />
|-<br />
| -t<br />
| Target wiki - The backup is restored in this wiki<br />
|-<br />
| -q<br />
| SMW query to select the pages to be restored. Note that the query is only used to select the page names the actual backup is then restored from the local backup.<br />
|-<br />
| -p<br />
| Names of the pages to be restored<br />
|-<br />
| --backupPath<br />
| define location of the backup. Default is the default backup location of the target wiki.<br />
|-<br />
<br />
|}<br />
If argument '''-s''' is used a page query is executed therefore all arguments related to an page query can be used such as '''-ui''' and '''--limit'''.<br />
<br />
== Examples ==<br />
=== --backupPath ===<br />
Use this argument to define a different backup folder<br />
====wikibackup====<br />
<syntaxhighlight lang="shell" line='line'><br />
$ wikibackup -s orth --backupPath "/home/user/wikibackup/orth_copy" -q "[[isA::Event]]" --limit 10<br />
<br />
downloading 10 pages from orth to /home/user/wikibackup/orth_copy<br />
1/10 ( 10%): downloading " DBKDA 2021" ...✅<br />
2/10 ( 20%): downloading "ENERGY 2021" ...✅<br />
3/10 ( 30%): downloading "ICAS 2021" ...✅<br />
4/10 ( 40%): downloading "ICNS 2021" ...✅<br />
5/10 ( 50%): downloading 2021 ICIMP ...✅<br />
6/10 ( 60%): downloading 3DUI 2020 ...✅<br />
7/10 ( 70%): downloading 3IA 2009 ...✅<br />
8/10 ( 80%): downloading 3PGIC 2010 ...✅<br />
9/10 ( 90%): downloading 4S4D 2017 ...✅<br />
10/10 ( 100%): downloading 5GU 2017 ...✅<br />
</syntaxhighlight><br />
<br />
====wikirestore====<br />
<syntaxhighlight lang="shell"><br />
$ wikirestore -t orth --backupPath "/home/user/wikibackup/orth_copy"<br />
<br />
restoring 10 pages from /home/user/wikibackup/orth_copy to orth<br />
1/10 ( 10%): restore 2021 ICIMP ...✅<br />
2/10 ( 20%): restore "ICNS 2021" ...✅<br />
3/10 ( 30%): restore 3PGIC 2010 ...✅<br />
4/10 ( 40%): restore 4S4D 2017 ...✅<br />
5/10 ( 50%): restore "ENERGY 2021" ...✅<br />
6/10 ( 60%): restore 3DUI 2020 ...✅<br />
7/10 ( 70%): restore " DBKDA 2021" ...✅<br />
8/10 ( 80%): restore 3IA 2009 ...✅<br />
9/10 ( 90%): restore "ICAS 2021" ...✅<br />
10/10 ( 100%): restore 5GU 2017 ...✅<br />
</syntaxhighlight><br />
<br />
=== Scenario: Restore triangle ===<br />
<syntaxhighlight lang="shell"><br />
$ wikirestore -s or -q "[[isA:Event]]" -t orth --backupPath "/home/user/wikibackup/orth_copy"<br />
</syntaxhighlight><br />
With this command we query all page names that are an Event from the wiki '''or''' and restore them in the wiki '''orth''' with the version of the page that is stored in '''/home/user/wikibackup/orth_copy'''.<br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highlight='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1243Py-3rdparty-mediawiki2021-03-17T19:38:45Z<p>Wf: /* shared script */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# [https://www.mediawiki.org/wiki/Manual:Pywikibot/de pywikibot]<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
== via pip ==<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki<br />
# alternatively if your pip is not a python3 pip<br />
pip3 install py-3rdparty-mediawiki<br />
</source><br />
=== upgrade ===<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki -U<br />
# alternatively if your pip is not a python3 pip<br />
pip3 install py-3rdparty-mediawiki -U<br />
</source><br />
<br />
== Via Source code ==<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikibackup / wikiedit / wiknuke / wikirestore/ wikiquery / wikiupload / wikiuser scripts =<br />
== Setup method ==<br />
If you installed with the method above console_script will have been added to your environment. You can e.g. check<br />
<source lang='bash' highlight='1'><br />
which wikipush<br />
/Users/wf/Library/Python/3.8/bin/wikipush<br />
</source><br />
and there should be a wikipush script in your path.<br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above. This approach is deprecated and therefore incomplete as of 2020-12<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash' highlight='1'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= wikibackup =<br />
== usage ==<br />
<source lang='bash'><br />
</source><br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3<br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"<br />
editing 1 pages in test (dry run)<br />
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍 |isA=CFP<br />
-|Acronym=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
-|Title=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Acronym=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Title=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
|Start date=2010/11/01<br />
}}<br />
-CALL FOR PAPER<br />
+CFP<br />
Journal: Advances in Multimedia - An International Journal (AMIJ)<br />
</source><br />
<br />
= wikirestore =<br />
Tool to restore wiki pages from an local backup, created with wikibackup, to an destination wiki.<br />
<br />
== Arguments ==<br />
{| class="wikitable"<br />
|-<br />
!| Argument <br />
!| Description<br />
|-<br />
| -s<br />
| Source wiki - Only used to query page names. The queried page names will then be looked up in the backup.<br />
|-<br />
| -t<br />
| Target wiki - The backup is restored in this wiki<br />
|-<br />
| -q<br />
| SMW query to select the pages to be restored. Note that the query is only used to select the page names the actual backup is then restored from the local backup.<br />
|-<br />
| -p<br />
| Names of the pages to be restored<br />
|-<br />
| --backupPath<br />
| define location of the backup. Default is the default backup location of the target wiki.<br />
|-<br />
<br />
|}<br />
If argument '''-s''' is used a page query is executed therefore all arguments related to an page query can be used such as '''-ui''' and '''--limit'''.<br />
<br />
== Examples ==<br />
=== --backupPath ===<br />
Use this argument to define a different backup folder<br />
====wikibackup====<br />
<syntaxhighlight lang="shell" line='line'><br />
$ wikibackup -s orth --backupPath "/home/user/wikibackup/orth_copy" -q "[[isA::Event]]" --limit 10<br />
<br />
downloading 10 pages from orth to /home/user/wikibackup/orth_copy<br />
1/10 ( 10%): downloading " DBKDA 2021" ...✅<br />
2/10 ( 20%): downloading "ENERGY 2021" ...✅<br />
3/10 ( 30%): downloading "ICAS 2021" ...✅<br />
4/10 ( 40%): downloading "ICNS 2021" ...✅<br />
5/10 ( 50%): downloading 2021 ICIMP ...✅<br />
6/10 ( 60%): downloading 3DUI 2020 ...✅<br />
7/10 ( 70%): downloading 3IA 2009 ...✅<br />
8/10 ( 80%): downloading 3PGIC 2010 ...✅<br />
9/10 ( 90%): downloading 4S4D 2017 ...✅<br />
10/10 ( 100%): downloading 5GU 2017 ...✅<br />
</syntaxhighlight><br />
<br />
====wikirestore====<br />
<syntaxhighlight lang="shell"><br />
$ wikirestore -t orth --backupPath "/home/user/wikibackup/orth_copy"<br />
<br />
restoring 10 pages from /home/user/wikibackup/orth_copy to orth<br />
1/10 ( 10%): restore 2021 ICIMP ...✅<br />
2/10 ( 20%): restore "ICNS 2021" ...✅<br />
3/10 ( 30%): restore 3PGIC 2010 ...✅<br />
4/10 ( 40%): restore 4S4D 2017 ...✅<br />
5/10 ( 50%): restore "ENERGY 2021" ...✅<br />
6/10 ( 60%): restore 3DUI 2020 ...✅<br />
7/10 ( 70%): restore " DBKDA 2021" ...✅<br />
8/10 ( 80%): restore 3IA 2009 ...✅<br />
9/10 ( 90%): restore "ICAS 2021" ...✅<br />
10/10 ( 100%): restore 5GU 2017 ...✅<br />
</syntaxhighlight><br />
<br />
=== Scenario: Restore triangle ===<br />
<syntaxhighlight lang="shell"><br />
$ wikirestore -s or -q "[[isA:Event]]" -t orth --backupPath "/home/user/wikibackup/orth_copy"<br />
</syntaxhighlight><br />
With this command we query all page names that are an Event from the wiki '''or''' and restore them in the wiki '''orth''' with the version of the page that is stored in '''/home/user/wikibackup/orth_copy'''.<br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highlight='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1242Py-3rdparty-mediawiki2021-02-25T16:33:49Z<p>Wf: /* Arguments */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# [https://www.mediawiki.org/wiki/Manual:Pywikibot/de pywikibot]<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
== via pip ==<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki<br />
# alternatively if your pip is not a python3 pip<br />
pip3 install py-3rdparty-mediawiki<br />
</source><br />
=== upgrade ===<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki -U<br />
# alternatively if your pip is not a python3 pip<br />
pip3 install py-3rdparty-mediawiki -U<br />
</source><br />
<br />
== Via Source code ==<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikibackup / wikiedit / wiknuke / wikirestore/ wikiquery / wikiupload / wikiuser scripts =<br />
== Setup method ==<br />
If you installed with the method above console_script will have been added to your environment. You can e.g. check<br />
<source lang='bash' highlight='1'><br />
which wikipush<br />
/Users/wf/Library/Python/3.8/bin/wikipush<br />
</source><br />
and there should be a wikipush script in your path.<br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash' highlight='1'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= wikibackup =<br />
== usage ==<br />
<source lang='bash'><br />
</source><br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3<br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"<br />
editing 1 pages in test (dry run)<br />
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍 |isA=CFP<br />
-|Acronym=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
-|Title=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Acronym=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Title=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
|Start date=2010/11/01<br />
}}<br />
-CALL FOR PAPER<br />
+CFP<br />
Journal: Advances in Multimedia - An International Journal (AMIJ)<br />
</source><br />
<br />
= wikirestore =<br />
Tool to restore wiki pages from an local backup, created with wikibackup, to an destination wiki.<br />
<br />
== Arguments ==<br />
{| class="wikitable"<br />
|-<br />
!| Argument <br />
!| Description<br />
|-<br />
| -s<br />
| Source wiki - Only used to query page names. The queried page names will then be looked up in the backup.<br />
|-<br />
| -t<br />
| Target wiki - The backup is restored in this wiki<br />
|-<br />
| -q<br />
| SMW query to select the pages to be restored. Note that the query is only used to select the page names the actual backup is then restored from the local backup.<br />
|-<br />
| -p<br />
| Names of the pages to be restored<br />
|-<br />
| --backupPath<br />
| define location of the backup. Default is the default backup location of the target wiki.<br />
|-<br />
<br />
|}<br />
If argument '''-s''' is used a page query is executed therefore all arguments related to an page query can be used such as '''-ui''' and '''--limit'''.<br />
<br />
== Examples ==<br />
=== --backupPath ===<br />
Use this argument to define a different backup folder<br />
====wikibackup====<br />
<syntaxhighlight lang="shell" line='line'><br />
$ wikibackup -s orth --backupPath "/home/user/wikibackup/orth_copy" -q "[[isA::Event]]" --limit 10<br />
<br />
downloading 10 pages from orth to /home/user/wikibackup/orth_copy<br />
1/10 ( 10%): downloading " DBKDA 2021" ...✅<br />
2/10 ( 20%): downloading "ENERGY 2021" ...✅<br />
3/10 ( 30%): downloading "ICAS 2021" ...✅<br />
4/10 ( 40%): downloading "ICNS 2021" ...✅<br />
5/10 ( 50%): downloading 2021 ICIMP ...✅<br />
6/10 ( 60%): downloading 3DUI 2020 ...✅<br />
7/10 ( 70%): downloading 3IA 2009 ...✅<br />
8/10 ( 80%): downloading 3PGIC 2010 ...✅<br />
9/10 ( 90%): downloading 4S4D 2017 ...✅<br />
10/10 ( 100%): downloading 5GU 2017 ...✅<br />
</syntaxhighlight><br />
<br />
====wikirestore====<br />
<syntaxhighlight lang="shell"><br />
$ wikirestore -t orth --backupPath "/home/user/wikibackup/orth_copy"<br />
<br />
restoring 10 pages from /home/user/wikibackup/orth_copy to orth<br />
1/10 ( 10%): restore 2021 ICIMP ...✅<br />
2/10 ( 20%): restore "ICNS 2021" ...✅<br />
3/10 ( 30%): restore 3PGIC 2010 ...✅<br />
4/10 ( 40%): restore 4S4D 2017 ...✅<br />
5/10 ( 50%): restore "ENERGY 2021" ...✅<br />
6/10 ( 60%): restore 3DUI 2020 ...✅<br />
7/10 ( 70%): restore " DBKDA 2021" ...✅<br />
8/10 ( 80%): restore 3IA 2009 ...✅<br />
9/10 ( 90%): restore "ICAS 2021" ...✅<br />
10/10 ( 100%): restore 5GU 2017 ...✅<br />
</syntaxhighlight><br />
<br />
=== Scenario: Restore triangle ===<br />
<syntaxhighlight lang="shell"><br />
$ wikirestore -s or -q "[[isA:Event]]" -t orth --backupPath "/home/user/wikibackup/orth_copy"<br />
</syntaxhighlight><br />
With this command we query all page names that are an Event from the wiki '''or''' and restore them in the wiki '''orth''' with the version of the page that is stored in '''/home/user/wikibackup/orth_copy'''.<br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highlight='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1241Py-3rdparty-mediawiki2021-02-25T15:49:25Z<p>Wf: /* wikiupload */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# [https://www.mediawiki.org/wiki/Manual:Pywikibot/de pywikibot]<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
== via pip ==<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki<br />
# alternatively if your pip is not a python3 pip<br />
pip3 install py-3rdparty-mediawiki<br />
</source><br />
=== upgrade ===<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki -U<br />
# alternatively if your pip is not a python3 pip<br />
pip3 install py-3rdparty-mediawiki -U<br />
</source><br />
<br />
== Via Source code ==<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikibackup / wikiedit / wiknuke / wikirestore/ wikiquery / wikiupload / wikiuser scripts =<br />
== Setup method ==<br />
If you installed with the method above console_script will have been added to your environment. You can e.g. check<br />
<source lang='bash' highlight='1'><br />
which wikipush<br />
/Users/wf/Library/Python/3.8/bin/wikipush<br />
</source><br />
and there should be a wikipush script in your path.<br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash' highlight='1'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= wikibackup =<br />
== usage ==<br />
<source lang='bash'><br />
</source><br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3<br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"<br />
editing 1 pages in test (dry run)<br />
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍 |isA=CFP<br />
-|Acronym=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
-|Title=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Acronym=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Title=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
|Start date=2010/11/01<br />
}}<br />
-CALL FOR PAPER<br />
+CFP<br />
Journal: Advances in Multimedia - An International Journal (AMIJ)<br />
</source><br />
<br />
= wikirestore =<br />
Tool to restore wiki pages from an local backup, created with wikibackup, to an destination wiki.<br />
<br />
= Arguments =<br />
{| class="wikitable"<br />
|-<br />
!| Argument <br />
!| Description<br />
|-<br />
| -s<br />
| Source wiki - Only used to query page names. The queried page names will then be looked up in the backup.<br />
|-<br />
| -t<br />
| Target wiki - The backup is restored in this wiki<br />
|-<br />
| -q<br />
| SMW query to select the pages to be restored. Note that the query is only used to select the page names the actual backup is then restored from the local backup.<br />
|-<br />
| -p<br />
| Names of the pages to be restored<br />
|-<br />
| --backupPath<br />
| define location of the backup. Default is the default backup location of the target wiki.<br />
|-<br />
<br />
|}<br />
If argument '''-s''' is used a page query is executed therefore all arguments related to an page query can be used such as '''-ui''' and '''--limit'''.<br />
<br />
== Examples ==<br />
=== --backupPath ===<br />
Use this argument to define a different backup folder<br />
====wikibackup====<br />
<syntaxhighlight lang="shell" line='line'><br />
$ wikibackup -s orth --backupPath "/home/user/wikibackup/orth_copy" -q "[[isA::Event]]" --limit 10<br />
<br />
downloading 10 pages from orth to /home/user/wikibackup/orth_copy<br />
1/10 ( 10%): downloading " DBKDA 2021" ...✅<br />
2/10 ( 20%): downloading "ENERGY 2021" ...✅<br />
3/10 ( 30%): downloading "ICAS 2021" ...✅<br />
4/10 ( 40%): downloading "ICNS 2021" ...✅<br />
5/10 ( 50%): downloading 2021 ICIMP ...✅<br />
6/10 ( 60%): downloading 3DUI 2020 ...✅<br />
7/10 ( 70%): downloading 3IA 2009 ...✅<br />
8/10 ( 80%): downloading 3PGIC 2010 ...✅<br />
9/10 ( 90%): downloading 4S4D 2017 ...✅<br />
10/10 ( 100%): downloading 5GU 2017 ...✅<br />
</syntaxhighlight><br />
<br />
====wikirestore====<br />
<syntaxhighlight lang="shell"><br />
$ wikirestore -t orth --backupPath "/home/user/wikibackup/orth_copy"<br />
<br />
restoring 10 pages from /home/user/wikibackup/orth_copy to orth<br />
1/10 ( 10%): restore 2021 ICIMP ...✅<br />
2/10 ( 20%): restore "ICNS 2021" ...✅<br />
3/10 ( 30%): restore 3PGIC 2010 ...✅<br />
4/10 ( 40%): restore 4S4D 2017 ...✅<br />
5/10 ( 50%): restore "ENERGY 2021" ...✅<br />
6/10 ( 60%): restore 3DUI 2020 ...✅<br />
7/10 ( 70%): restore " DBKDA 2021" ...✅<br />
8/10 ( 80%): restore 3IA 2009 ...✅<br />
9/10 ( 90%): restore "ICAS 2021" ...✅<br />
10/10 ( 100%): restore 5GU 2017 ...✅<br />
</syntaxhighlight><br />
<br />
=== Scenario: Restore triangle ===<br />
<syntaxhighlight lang="shell"><br />
$ wikirestore -s or -q "[[isA:Event]]" -t orth --backupPath "/home/user/wikibackup/orth_copy"<br />
</syntaxhighlight><br />
With this command we query all page names that are an Event from the wiki '''or''' and restore them in the wiki '''orth''' with the version of the page that is stored in '''/home/user/wikibackup/orth_copy'''.<br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highlight='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1240Py-3rdparty-mediawiki2021-02-25T15:47:01Z<p>Wf: /* wikipush / wikibackup / wikiedit / wiknuke / wikupload / wikiuser scripts */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# [https://www.mediawiki.org/wiki/Manual:Pywikibot/de pywikibot]<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
== via pip ==<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki<br />
# alternatively if your pip is not a python3 pip<br />
pip3 install py-3rdparty-mediawiki<br />
</source><br />
=== upgrade ===<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki -U<br />
# alternatively if your pip is not a python3 pip<br />
pip3 install py-3rdparty-mediawiki -U<br />
</source><br />
<br />
== Via Source code ==<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikibackup / wikiedit / wiknuke / wikirestore/ wikiquery / wikiupload / wikiuser scripts =<br />
== Setup method ==<br />
If you installed with the method above console_script will have been added to your environment. You can e.g. check<br />
<source lang='bash' highlight='1'><br />
which wikipush<br />
/Users/wf/Library/Python/3.8/bin/wikipush<br />
</source><br />
and there should be a wikipush script in your path.<br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash' highlight='1'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= wikibackup =<br />
== usage ==<br />
<source lang='bash'><br />
</source><br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3<br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"<br />
editing 1 pages in test (dry run)<br />
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍 |isA=CFP<br />
-|Acronym=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
-|Title=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Acronym=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Title=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
|Start date=2010/11/01<br />
}}<br />
-CALL FOR PAPER<br />
+CFP<br />
Journal: Advances in Multimedia - An International Journal (AMIJ)<br />
</source><br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highlight='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1239Py-3rdparty-mediawiki2020-12-27T11:54:04Z<p>Wf: /* Linked Script method */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# [https://www.mediawiki.org/wiki/Manual:Pywikibot/de pywikibot]<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
== via pip ==<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki<br />
# alternatively if your pip is not a python3 pip<br />
pip3 install py-3rdparty-mediawiki<br />
</source><br />
=== upgrade ===<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki -U<br />
# alternatively if your pip is not a python3 pip<br />
pip3 install py-3rdparty-mediawiki -U<br />
</source><br />
<br />
== Via Source code ==<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikibackup / wikiedit / wiknuke / wikupload / wikiuser scripts =<br />
== Setup method ==<br />
If you installed with the method above console_script will have been added to your environment. You can e.g. check<br />
<source lang='bash' highlight='1'><br />
which wikipush<br />
/Users/wf/Library/Python/3.8/bin/wikipush<br />
</source><br />
and there should be a wikipush script in your path.<br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash' highlight='1'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= wikibackup =<br />
== usage ==<br />
<source lang='bash'><br />
</source><br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3<br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"<br />
editing 1 pages in test (dry run)<br />
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍 |isA=CFP<br />
-|Acronym=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
-|Title=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Acronym=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Title=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
|Start date=2010/11/01<br />
}}<br />
-CALL FOR PAPER<br />
+CFP<br />
Journal: Advances in Multimedia - An International Journal (AMIJ)<br />
</source><br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highlight='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1238Py-3rdparty-mediawiki2020-12-27T09:34:13Z<p>Wf: /* What is it */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# [https://www.mediawiki.org/wiki/Manual:Pywikibot/de pywikibot]<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
== via pip ==<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki<br />
# alternatively if your pip is not a python3 pip<br />
pip3 install py-3rdparty-mediawiki<br />
</source><br />
=== upgrade ===<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki -U<br />
# alternatively if your pip is not a python3 pip<br />
pip3 install py-3rdparty-mediawiki -U<br />
</source><br />
<br />
== Via Source code ==<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikibackup / wikiedit / wiknuke / wikupload / wikiuser scripts =<br />
== Setup method ==<br />
If you installed with the method above console_script will have been added to your environment. You can e.g. check<br />
<source lang='bash' highlight='1'><br />
which wikipush<br />
/Users/wf/Library/Python/3.8/bin/wikipush<br />
</source><br />
and there should be a wikipush script in your path.<br />
== Linked Script method ==<br />
The scripts for this method are in the scripts directory. They should be linked with the needed names<br />
<source lang='bash'><br />
ln wikipush wikibackup<br />
ln wikipush wikiuser<br />
...<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
...<br />
</source><br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash' highlight='1'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= wikibackup =<br />
== usage ==<br />
<source lang='bash'><br />
</source><br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3<br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"<br />
editing 1 pages in test (dry run)<br />
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍 |isA=CFP<br />
-|Acronym=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
-|Title=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Acronym=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Title=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
|Start date=2010/11/01<br />
}}<br />
-CALL FOR PAPER<br />
+CFP<br />
Journal: Advances in Multimedia - An International Journal (AMIJ)<br />
</source><br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highlight='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1237Py-3rdparty-mediawiki2020-12-18T06:55:12Z<p>Wf: /* WikiNuke */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
== via pip ==<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki<br />
# alternatively if your pip is not a python3 pip<br />
pip3 install py-3rdparty-mediawiki<br />
</source><br />
=== upgrade ===<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki -U<br />
# alternatively if your pip is not a python3 pip<br />
pip3 install py-3rdparty-mediawiki -U<br />
</source><br />
<br />
== Via Source code ==<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikibackup / wikiedit / wiknuke / wikupload / wikiuser scripts =<br />
== Setup method ==<br />
If you installed with the method above console_script will have been added to your environment. You can e.g. check<br />
<source lang='bash' highlight='1'><br />
which wikipush<br />
/Users/wf/Library/Python/3.8/bin/wikipush<br />
</source><br />
and there should be a wikipush script in your path.<br />
== Linked Script method ==<br />
The scripts for this method are in the scripts directory. They should be linked with the needed names<br />
<source lang='bash'><br />
ln wikipush wikibackup<br />
ln wikipush wikiuser<br />
...<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
...<br />
</source><br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash' highlight='1'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= wikibackup =<br />
== usage ==<br />
<source lang='bash'><br />
</source><br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3<br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"<br />
editing 1 pages in test (dry run)<br />
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍 |isA=CFP<br />
-|Acronym=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
-|Title=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Acronym=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Title=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
|Start date=2010/11/01<br />
}}<br />
-CALL FOR PAPER<br />
+CFP<br />
Journal: Advances in Multimedia - An International Journal (AMIJ)<br />
</source><br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highlight='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1236Py-3rdparty-mediawiki2020-12-18T06:51:51Z<p>Wf: /* via pip */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
== via pip ==<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki<br />
# alternatively if your pip is not a python3 pip<br />
pip3 install py-3rdparty-mediawiki<br />
</source><br />
=== upgrade ===<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki -U<br />
# alternatively if your pip is not a python3 pip<br />
pip3 install py-3rdparty-mediawiki -U<br />
</source><br />
<br />
== Via Source code ==<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikibackup / wikiedit / wiknuke / wikupload / wikiuser scripts =<br />
== Setup method ==<br />
If you installed with the method above console_script will have been added to your environment. You can e.g. check<br />
<source lang='bash' highlight='1'><br />
which wikipush<br />
/Users/wf/Library/Python/3.8/bin/wikipush<br />
</source><br />
and there should be a wikipush script in your path.<br />
== Linked Script method ==<br />
The scripts for this method are in the scripts directory. They should be linked with the needed names<br />
<source lang='bash'><br />
ln wikipush wikibackup<br />
ln wikipush wikiuser<br />
...<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
...<br />
</source><br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash' highlight='1'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3<br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"<br />
editing 1 pages in test (dry run)<br />
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍 |isA=CFP<br />
-|Acronym=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
-|Title=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Acronym=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Title=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
|Start date=2010/11/01<br />
}}<br />
-CALL FOR PAPER<br />
+CFP<br />
Journal: Advances in Multimedia - An International Journal (AMIJ)<br />
</source><br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highlight='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1235Py-3rdparty-mediawiki2020-12-14T14:05:22Z<p>Wf: /* Installation */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
== via pip ==<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki<br />
</source><br />
=== upgrade ===<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki -U<br />
</source><br />
<br />
== Via Source code ==<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikibackup / wikiedit / wiknuke / wikupload / wikiuser scripts =<br />
== Setup method ==<br />
If you installed with the method above console_script will have been added to your environment. You can e.g. check<br />
<source lang='bash' highlight='1'><br />
which wikipush<br />
/Users/wf/Library/Python/3.8/bin/wikipush<br />
</source><br />
and there should be a wikipush script in your path.<br />
== Linked Script method ==<br />
The scripts for this method are in the scripts directory. They should be linked with the needed names<br />
<source lang='bash'><br />
ln wikipush wikibackup<br />
ln wikipush wikiuser<br />
...<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
...<br />
</source><br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash' highlight='1'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3<br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"<br />
editing 1 pages in test (dry run)<br />
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍 |isA=CFP<br />
-|Acronym=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
-|Title=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Acronym=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Title=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
|Start date=2010/11/01<br />
}}<br />
-CALL FOR PAPER<br />
+CFP<br />
Journal: Advances in Multimedia - An International Journal (AMIJ)<br />
</source><br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highlight='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1234Py-3rdparty-mediawiki2020-12-14T14:04:57Z<p>Wf: /* Installation */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
== via pip ===<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki<br />
</source><br />
=== upgrade ===<br />
<source lang='bash'><br />
pip install py-3rdparty-mediawiki -U<br />
</source><br />
<br />
== Via Source code ==<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikibackup / wikiedit / wiknuke / wikupload / wikiuser scripts =<br />
== Setup method ==<br />
If you installed with the method above console_script will have been added to your environment. You can e.g. check<br />
<source lang='bash' highlight='1'><br />
which wikipush<br />
/Users/wf/Library/Python/3.8/bin/wikipush<br />
</source><br />
and there should be a wikipush script in your path.<br />
== Linked Script method ==<br />
The scripts for this method are in the scripts directory. They should be linked with the needed names<br />
<source lang='bash'><br />
ln wikipush wikibackup<br />
ln wikipush wikiuser<br />
...<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
...<br />
</source><br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash' highlight='1'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3<br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"<br />
editing 1 pages in test (dry run)<br />
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍 |isA=CFP<br />
-|Acronym=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
-|Title=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Acronym=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Title=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
|Start date=2010/11/01<br />
}}<br />
-CALL FOR PAPER<br />
+CFP<br />
Journal: Advances in Multimedia - An International Journal (AMIJ)<br />
</source><br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highlight='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1233Py-3rdparty-mediawiki2020-12-14T12:27:03Z<p>Wf: /* wikipush / wikiedit / wiknuke / wikupload / wikiuser scripts */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikibackup / wikiedit / wiknuke / wikupload / wikiuser scripts =<br />
== Setup method ==<br />
If you installed with the method above console_script will have been added to your environment. You can e.g. check<br />
<source lang='bash' highlight='1'><br />
which wikipush<br />
/Users/wf/Library/Python/3.8/bin/wikipush<br />
</source><br />
and there should be a wikipush script in your path.<br />
== Linked Script method ==<br />
The scripts for this method are in the scripts directory. They should be linked with the needed names<br />
<source lang='bash'><br />
ln wikipush wikibackup<br />
ln wikipush wikiuser<br />
...<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
...<br />
</source><br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash' highlight='1'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3<br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"<br />
editing 1 pages in test (dry run)<br />
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍 |isA=CFP<br />
-|Acronym=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
-|Title=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Acronym=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Title=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
|Start date=2010/11/01<br />
}}<br />
-CALL FOR PAPER<br />
+CFP<br />
Journal: Advances in Multimedia - An International Journal (AMIJ)<br />
</source><br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highlight='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1232Py-3rdparty-mediawiki2020-12-06T14:39:53Z<p>Wf: /* wikipush / wikiedit / wiknuke / wikupload / wikiuser scripts */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikiedit / wiknuke / wikupload / wikiuser scripts =<br />
== Setup method ==<br />
If you installed with the method above console_script will have been added to your environment. You can e.g. check<br />
<source lang='bash' highlight='1'><br />
which wikipush<br />
/Users/wf/Library/Python/3.8/bin/wikipush<br />
</source><br />
and there should be a wikipush script in your path.<br />
== Linked Script method ==<br />
The scripts for this method are in the scripts directory. They should be linked with the needed names<br />
<source lang='bash'><br />
ln wikipush wikibackup<br />
ln wikipush wikiuser<br />
...<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
...<br />
</source><br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash' highlight='1'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3<br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"<br />
editing 1 pages in test (dry run)<br />
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍 |isA=CFP<br />
-|Acronym=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
-|Title=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Acronym=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Title=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
|Start date=2010/11/01<br />
}}<br />
-CALL FOR PAPER<br />
+CFP<br />
Journal: Advances in Multimedia - An International Journal (AMIJ)<br />
</source><br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highlight='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1231Py-3rdparty-mediawiki2020-12-05T11:16:52Z<p>Wf: /* wikipush / wikiedit / wiknuke / wikupload / wikiuser scripts */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikiedit / wiknuke / wikupload / wikiuser scripts =<br />
== Linked Script method ==<br />
The scripts for this method are in the scripts directory. They should be linked with the needed names<br />
<source lang='bash'><br />
ln wikipush wikibackup<br />
ln wikipush wikiuser<br />
...<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
...<br />
</source><br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash' highlight='1'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3<br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"<br />
editing 1 pages in test (dry run)<br />
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍 |isA=CFP<br />
-|Acronym=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
-|Title=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Acronym=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Title=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
|Start date=2010/11/01<br />
}}<br />
-CALL FOR PAPER<br />
+CFP<br />
Journal: Advances in Multimedia - An International Journal (AMIJ)<br />
</source><br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highlight='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1230Py-3rdparty-mediawiki2020-11-25T16:46:28Z<p>Wf: /* Example */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikiedit / wiknuke / wikupload / wikiuser scripts =<br />
This script is in the scripts directory. It should be linked with three names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
ln wikipush wikinuke<br />
ln wikipush wikiedit<br />
ln wikipush wikiupload<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikinuke .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiedit .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiupload .<br />
</source><br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash' highlight='1'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3<br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"<br />
editing 1 pages in test (dry run)<br />
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍 |isA=CFP<br />
-|Acronym=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
-|Title=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Acronym=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Title=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
|Start date=2010/11/01<br />
}}<br />
-CALL FOR PAPER<br />
+CFP<br />
Journal: Advances in Multimedia - An International Journal (AMIJ)<br />
</source><br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highlight='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1229Py-3rdparty-mediawiki2020-11-17T13:39:47Z<p>Wf: /* example */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikiedit / wiknuke / wikupload / wikiuser scripts =<br />
This script is in the scripts directory. It should be linked with three names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
ln wikipush wikinuke<br />
ln wikipush wikiedit<br />
ln wikipush wikiupload<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikinuke .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiedit .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiupload .<br />
</source><br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash' highlight='1'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3<br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"<br />
editing 1 pages in test (dry run)<br />
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍 |isA=CFP<br />
-|Acronym=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
-|Title=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Acronym=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Title=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
|Start date=2010/11/01<br />
}}<br />
-CALL FOR PAPER<br />
+CFP<br />
Journal: Advances in Multimedia - An International Journal (AMIJ)<br />
</source><br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highligt='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1228Py-3rdparty-mediawiki2020-11-17T13:39:28Z<p>Wf: /* Example */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikiedit / wiknuke / wikupload / wikiuser scripts =<br />
This script is in the scripts directory. It should be linked with three names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
ln wikipush wikinuke<br />
ln wikipush wikiedit<br />
ln wikipush wikiupload<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikinuke .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiedit .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiupload .<br />
</source><br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash' highlight='1'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3<br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash' highlight='1'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"<br />
editing 1 pages in test (dry run)<br />
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍 |isA=CFP<br />
-|Acronym=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
-|Title=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Acronym=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Title=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
|Start date=2010/11/01<br />
}}<br />
-CALL FOR PAPER<br />
+CFP<br />
Journal: Advances in Multimedia - An International Journal (AMIJ)<br />
</source><br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highligt='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1227Py-3rdparty-mediawiki2020-11-17T13:37:21Z<p>Wf: /* Example */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikiedit / wiknuke / wikupload / wikiuser scripts =<br />
This script is in the scripts directory. It should be linked with three names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
ln wikipush wikinuke<br />
ln wikipush wikiedit<br />
ln wikipush wikiupload<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikinuke .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiedit .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiupload .<br />
</source><br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash' highlight='1'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash'><br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"<br />
editing 1 pages in test (dry run)<br />
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍 |isA=CFP<br />
-|Acronym=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
-|Title=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Acronym=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Title=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
|Start date=2010/11/01<br />
}}<br />
-CALL FOR PAPER<br />
+CFP<br />
Journal: Advances in Multimedia - An International Journal (AMIJ)<br />
</source><br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highligt='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1226Py-3rdparty-mediawiki2020-11-17T13:36:46Z<p>Wf: /* example */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikiedit / wiknuke / wikupload / wikiuser scripts =<br />
This script is in the scripts directory. It should be linked with three names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
ln wikipush wikinuke<br />
ln wikipush wikiedit<br />
ln wikipush wikiupload<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikinuke .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiedit .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiupload .<br />
</source><br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash'><br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
== example ==<br />
<source lang='bash' highlight='1'><br />
wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"<br />
editing 1 pages in test (dry run)<br />
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍 |isA=CFP<br />
-|Acronym=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
-|Title=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Acronym=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Title=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
|Start date=2010/11/01<br />
}}<br />
-CALL FOR PAPER<br />
+CFP<br />
Journal: Advances in Multimedia - An International Journal (AMIJ)<br />
</source><br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highligt='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1225Py-3rdparty-mediawiki2020-11-17T13:36:11Z<p>Wf: /* wikiupload */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikiedit / wiknuke / wikupload / wikiuser scripts =<br />
This script is in the scripts directory. It should be linked with three names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
ln wikipush wikinuke<br />
ln wikipush wikiedit<br />
ln wikipush wikiupload<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikinuke .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiedit .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiupload .<br />
</source><br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash'><br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
== example ==<br />
<source lang='bash'><br />
wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"<br />
editing 1 pages in test (dry run)<br />
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍 |isA=CFP<br />
-|Acronym=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
-|Title=CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Acronym=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
+|Title=CFP Journal: Advances in Multimedia - An International Journal (AMIJ) <br />
|Start date=2010/11/01<br />
}}<br />
-CALL FOR PAPER<br />
+CFP<br />
Journal: Advances in Multimedia - An International Journal (AMIJ)<br />
</source><br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highligt='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1224Py-3rdparty-mediawiki2020-11-17T13:35:21Z<p>Wf: /* Example */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikiedit / wiknuke / wikupload / wikiuser scripts =<br />
This script is in the scripts directory. It should be linked with three names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
ln wikipush wikinuke<br />
ln wikipush wikiedit<br />
ln wikipush wikiupload<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikinuke .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiedit .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiupload .<br />
</source><br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
== Example ==<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash'><br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highligt='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1223Py-3rdparty-mediawiki2020-11-17T13:26:22Z<p>Wf: /* usage */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikiedit / wiknuke / wikupload / wikiuser scripts =<br />
This script is in the scripts directory. It should be linked with three names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
ln wikipush wikinuke<br />
ln wikipush wikiedit<br />
ln wikipush wikiupload<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikinuke .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiedit .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiupload .<br />
</source><br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
=== Example ===<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash'><br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== example ==<br />
<source lang='bash'><br />
wikiupload -t test --files car.png<br />
uploading 1 files to test<br />
1/1 ( 100%): uploading car.png ...✅<br />
</source><br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highligt='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1222Py-3rdparty-mediawiki2020-11-17T13:24:29Z<p>Wf: /* wikiupload */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikiedit / wiknuke / wikupload / wikiuser scripts =<br />
This script is in the scripts directory. It should be linked with three names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
ln wikipush wikinuke<br />
ln wikipush wikiedit<br />
ln wikipush wikiupload<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikinuke .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiedit .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiupload .<br />
</source><br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
=== Example ===<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash'><br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be uploaded<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== usage ==<br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highligt='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1221Py-3rdparty-mediawiki2020-11-17T13:23:49Z<p>Wf: /* WikiUser */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikiedit / wiknuke / wikupload / wikiuser scripts =<br />
This script is in the scripts directory. It should be linked with three names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
ln wikipush wikinuke<br />
ln wikipush wikiedit<br />
ln wikipush wikiupload<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikinuke .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiedit .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiupload .<br />
</source><br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
=== Example ===<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash'><br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
= wikiupload =<br />
wikiupload.py allows to mass upload files<br />
== usage ==<br />
<source lang='bash'><br />
wikiupload -h<br />
usage: wikiupload.py [-h] [-d] [-V] --files FILES [FILES ...] [-f] -t TARGET<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--files FILES [FILES ...]<br />
list of files to be pushed<br />
-f, --force force to (re)upload existing files - default is false<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
</source><br />
<br />
== usage ==<br />
<br />
= wikiuser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highligt='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1220Py-3rdparty-mediawiki2020-11-17T13:00:03Z<p>Wf: /* wikipush / wikiedit / wiknuke / wikiuser scripts */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikiedit / wiknuke / wikupload / wikiuser scripts =<br />
This script is in the scripts directory. It should be linked with three names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
ln wikipush wikinuke<br />
ln wikipush wikiedit<br />
ln wikipush wikiupload<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikinuke .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiedit .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiupload .<br />
</source><br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
=== Example ===<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash'><br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
= WikiUser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highligt='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1219Py-3rdparty-mediawiki2020-11-17T12:57:48Z<p>Wf: /* wikipush / wikiedit / wiknuke / wikiuser scripts */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikiedit / wiknuke / wikiuser scripts =<br />
This script is in the scripts directory. It should be linked with three names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
ln wikipush wikinuke<br />
ln wikipush wikiedit<br />
ln wikipush wikiupload<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikinuke .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiedit .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiupload .<br />
</source><br />
== shared script ==<br />
This script is the base script called "wikipush" which can be used using different names by hard linking as outlined above<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
"wikiupload")<br />
python -m wikibot.wikiupload "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
=== Example ===<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash'><br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
= WikiUser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highligt='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1218Py-3rdparty-mediawiki2020-11-15T16:20:40Z<p>Wf: /* WikiUser */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikiedit / wiknuke / wikiuser scripts =<br />
This script is in the scripts directory. It should be linked with three names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
ln wikipush wikinuke<br />
ln wikipush wikiedit<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikinuke .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiedit .<br />
</source><br />
<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
=== Example ===<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash'><br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiEdit =<br />
wikiedit.py allows mass editing of pages using python regular expressions<br />
== usage ==<br />
<source lang='bash'><br />
wikiedit -h<br />
usage: wikiedit.py [-h] [-d] [-V] --search SEARCH --replace REPLACE [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET<br />
[-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
--search SEARCH search pattern<br />
--replace REPLACE replace pattern<br />
-f, --force force to edit pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
= WikiUser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highligt='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1217Py-3rdparty-mediawiki2020-11-15T16:18:49Z<p>Wf: /* wikipush / wikuser / wikinuke scripts */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikiedit / wiknuke / wikiuser scripts =<br />
This script is in the scripts directory. It should be linked with three names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
ln wikipush wikinuke<br />
ln wikipush wikiedit<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikinuke .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiedit .<br />
</source><br />
<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(python -c "import os;import sys;print (os.path.realpath(sys.argv[1]))" $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiedit")<br />
python -m wikibot.wikiedit "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
*)<br />
echo "undefined wikipush script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
=== Example ===<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash'><br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiUser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highligt='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1216Py-3rdparty-mediawiki2020-11-12T13:52:16Z<p>Wf: /* WikiUser */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikuser / wikinuke scripts =<br />
This script is in the scripts directory. It should be linked with three names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
ln wikipush wikinuke<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikinuke .<br />
</source><br />
<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(readlink -nf $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
*)<br />
echo "undefined script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiNuke =<br />
wikinukes.py allows mass deletion of pages<br />
== usage ==<br />
<source lang='bash'><br />
usage: wikinuke.py [-h] [-d] [-V] [-f] [-q QUERY] [-qf QUERYFIELD] -t TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-11-12<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-f, --force force to delete pages - default is 'dry' run only listing pages<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-qf QUERYFIELD, --queryField QUERYFIELD<br />
query result field which contains page<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
<br />
</source><br />
=== Example ===<br />
The default behavior is a dry run only listing whether the pages exist<br />
<source lang='bash'><br />
deleting 3 pages in test (dry run)<br />
1/3 ( 33%): deleting deleteMe1 ...👍<br />
2/3 ( 67%): deleting deleteMe2 ...👍<br />
3/3 ( 100%): deleting deleteMe3 ...👍<br />
</source><br />
After checking you might want to (carefully) use the "-f" option to actually force the deletion:<br />
<source lang='bash'><br />
wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f<br />
deleting 3 pages in test (forced)<br />
1/3 ( 33%): deleting deleteMe1 ...✅<br />
2/3 ( 67%): deleting deleteMe2 ...✅<br />
3/3 ( 100%): deleting deleteMe3 ...✅<br />
</source><br />
<br />
= WikiUser =<br />
wikiuser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highligt='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1215Py-3rdparty-mediawiki2020-11-12T13:47:39Z<p>Wf: /* wikipush / wikuser script */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikuser / wikinuke scripts =<br />
This script is in the scripts directory. It should be linked with three names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
ln wikipush wikinuke<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikinuke .<br />
</source><br />
<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(readlink -nf $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
"wikinuke")<br />
python -m wikibot.wikinuke "$@"<br />
;;<br />
*)<br />
echo "undefined script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiUser =<br />
WikiUser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highligt='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1214Py-3rdparty-mediawiki2020-11-04T14:09:46Z<p>Wf: /* user-config.py */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikuser script =<br />
This script is in the scripts directory. It should be linked with two names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
</source><br />
<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(readlink -nf $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
*)<br />
echo "undefined script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiUser =<br />
WikiUser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highligt='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
# avoid warnings ...<br />
family='bitplan'<br />
mylang='en'<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1213Py-3rdparty-mediawiki2020-11-03T15:31:14Z<p>Wf: /* usage */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikuser script =<br />
This script is in the scripts directory. It should be linked with two names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
</source><br />
<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(readlink -nf $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
*)<br />
echo "undefined script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
== Example ==<br />
<source lang='bash'><br />
wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
copying 4 pages from smw to test2<br />
copying Demo:Tokyo ...✅<br />
copying image File:SMW-Info-button.png ...✅<br />
copying image File:Tokyo-Tsukishima-0011.jpg ...✅<br />
copying Vienna ...✅<br />
copying Warsaw ...✅<br />
copying image File:6140285934 02e81b845f z.jpg ...✅<br />
copying Demo:Würzburg ...✅<br />
</source><br />
<br />
= WikiUser =<br />
WikiUser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highligt='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Property:Link_title&diff=1212Property:Link title2020-11-03T15:29:04Z<p>Wf: pushed by wikipush</p>
<hr />
<div>This property is used by the template {{Link|target=Template:Link}}.<br />
It has the type [[Has type::text]]</div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Property:Link_targetUrl&diff=1211Property:Link targetUrl2020-11-03T15:28:53Z<p>Wf: pushed by wikipush</p>
<hr />
<div>This property is used by the template {{Link|target=Template:Link}}.<br />
It has the type [[Has type::url]]</div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Property:Link_targetPage&diff=1210Property:Link targetPage2020-11-03T15:28:44Z<p>Wf: pushed by wikipush</p>
<hr />
<div>This property is used by the template {{Link|target=Template:Link}}.<br />
It has the type [[Has type::page]]</div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Property:Link_target&diff=1209Property:Link target2020-11-03T15:28:38Z<p>Wf: pushed by wikipush</p>
<hr />
<div>This property is used by the template {{Link|target=Template:Link}}.<br />
It has the type [[Has type::text]] which can be a page or an URL</div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Template:Link&diff=1208Template:Link2020-11-03T15:28:05Z<p>Wf: pushed by wikipush</p>
<hr />
<div><noinclude><!-- THIS FILE IS PROTECTED - smartGENERATOR WILL NOT OVERWRITE IT -->{{TemplateSequence<br />
|prev=Template:Languagelink<br />
|next=Template:MdiIcon<br />
}}<br />
== template purpose ==<br />
This is a Template for internal and external Links in WikiSon notation.<br />
=== Motivation ===<br />
In Mediawiki there are at least five different ways to use a link - we'd like to hide this complexity and add new functionality:<br />
# <pre>[[Main Page]]</pre>[[Main Page]] - internal link with no text <br />
# <pre>[[Main Page|Start Page]]</pre>[[Main Page|Start Page]] - internal link with text <br />
# <pre>[http://partner.bitplan.com] </pre>[http://partner.bitplan.com] - external link as footnote <br />
# <pre>[http://partner.bitplan.com BITPlan partner site] </pre>[http://partner.bitplan.com BITPlan partner site] - external link with text <br />
# <pre>http://partner.bitplan.com </pre>http://partner.bitplan.com - automatic external link<br />
<br />
== WikiSon Link ==<br />
=== Motivation ===<br />
The Concept behind a link is<br />
<uml><br />
Class Link {<br />
target<br />
title<br />
}<br />
' BITPlan Corporate identity skin params<br />
' Copyright (c) 2015 BITPlan GmbH<br />
' see http://wiki.bitplan.com/PlantUmlSkinParams#BITPlanCI<br />
' skinparams generated by com.bitplan.restmodelmanager<br />
hide Circle<br />
skinparam note{<br />
BackGroundColor #FFFFFF<br />
FontSize 14<br />
ArrowColor #FF8000<br />
BorderColor #FF8000<br />
FontColor black<br />
FontName Technical<br />
}<br />
<br />
skinparam component{<br />
BackGroundColor #FFFFFF<br />
FontSize 14<br />
ArrowColor #FF8000<br />
BorderColor #FF8000<br />
FontColor black<br />
FontName Arial<br />
}<br />
<br />
skinparam package{<br />
BackGroundColor #FFFFFF<br />
FontSize 14<br />
ArrowColor #FF8000<br />
BorderColor #FF8000<br />
FontColor black<br />
FontName Arial<br />
}<br />
<br />
skinparam usecase{<br />
BackGroundColor #FFFFFF<br />
FontSize 14<br />
ArrowColor #FF8000<br />
BorderColor #FF8000<br />
FontColor black<br />
FontName Arial<br />
}<br />
<br />
skinparam activity{<br />
BackGroundColor #FFFFFF<br />
FontSize 14<br />
ArrowColor #FF8000<br />
BorderColor #FF8000<br />
FontColor black<br />
FontName Arial<br />
}<br />
<br />
skinparam classAttribute{<br />
BackGroundColor #FFFFFF<br />
FontSize 14<br />
ArrowColor #FF8000<br />
BorderColor #FF8000<br />
FontColor black<br />
FontName Technical<br />
}<br />
<br />
skinparam interface{<br />
BackGroundColor #FFFFFF<br />
FontSize 14<br />
ArrowColor #FF8000<br />
BorderColor #FF8000<br />
FontColor black<br />
FontName Arial<br />
}<br />
<br />
skinparam class{<br />
BackGroundColor #FFFFFF<br />
FontSize 14<br />
ArrowColor #FF8000<br />
BorderColor #FF8000<br />
FontColor black<br />
FontName Technical<br />
}<br />
</uml><br />
This calls for the WikiSon notation <br />
<pre><br />
{{Link<br />
|target=sometarget<br />
|title=sometitle<br />
}}<br />
</pre><br />
<br />
=== Link as WikiSon ===<br />
Using the WikiSon Concept approach the Link Concept is represented via<br />
the Wiki [[:Category:Link]]<br><br />
Especially there is a [[List of Links]] page available.<br />
<br />
Properties set:<br />
* {{Link|target=Property:Link targetUrl}}<br />
<br />
=== Examples ===<br />
<pre><br />
{{Link}}<br />
</pre><br />
internal default link to Main Page<br />
{{Link}}<br />
<pre><br />
{{Link|target=Main Page}}<br />
</pre><br />
internal link to Main Page<br />
{{Link|target=Main Page}}<br />
<pre><br />
{{Link|target=Main Page|title=Main Page}}<br />
</pre><br />
internal link to Main Page with title<br />
{{Link|target=Main Page|title=Main Page}}<br />
<br />
<pre><br />
{{Link|target=http://partner.bitplan.com}}<br />
</pre><br />
external link<br />
{{Link|target=http://partner.bitplan.com}}<br />
<br />
<pre><br />
{{Link|target=http://partner.bitplan.com|title=BITPlan Partner wiki}}<br />
</pre><br />
external link with title<br />
{{Link|target=http://partner.bitplan.com|title=BITPlan Partner wiki}}<br />
<br />
=== implementation ===<br />
==== Prerequisite ====<br />
LocalSettings.php needs to have the StringFunctions enabled:<br />
<source lang='php'><br />
# WF 2015-01-20<br />
# allow string functions<br />
$wgPFEnableStringFunctions=true;<br />
</source><br />
<br />
==== Template source ====<br />
The complexity of this template macro needs to be hidden<br />
===== original Link Template =====<br />
<pre><br />
{{#set:Link target={{{target|}}}<br />
|Link title={{{title|}}}<br />
}}{{#ifeq: <br />
{{#sub:{{{target|}}}|0|4}} <br />
| http | {{#set:Link targetUrl={{{target|}}}}}{{#if: {{{title|}}} <br />
| [{{{target|http://www.smartMediaWiki.com}}} {{{title}}}] <br />
| [{{{target|http://www.smartMediaWiki.com}}}] <br />
}}| {{#set:Link targetPage={{{target|}}}}}{{#if: {{{title|}}} <br />
| [[{{{target|Main Page}}}|{{{title}}}]] <br />
| [[{{{target|Main Page}}}]]<br />
}}}}[[Category:Link]]<br />
</pre><br />
===== pretty printed Template macro =====<br />
this version would unfortunately create unwanted newlines in the macro result<br />
<source lang='html4strict'><br />
<!-- set concept attributes target (mandatory) and title (optional) --><br />
{{#set:Link target={{{target|}}}<br />
|Link title={{{title|}}}<br />
}}<br />
<!-- check whether link is external or internal by comparing the firsts 4 chars with "http" --><br />
{{#ifeq: <br />
{{#sub:{{{target|}}}|0|4}} <br />
<br />
| http <br />
<br />
| <!-- in the http case (external link) set the targetURL property - it has the type "URL" and not "Text" like target or "Page" like targetPage --><br />
{{#set:Link targetUrl={{{target|}}}}}<br />
<br />
<!-- display external link with our without title --><br />
{{#if: {{{title|}}} <br />
| [{{{target|http://www.smartMediaWiki.com}}} {{{title}}}] <br />
| [{{{target|http://www.smartMediaWiki.com}}}] <br />
}}<br />
<br />
| <!-- in the non-http case (internal link) set the targetPage property - it has the type "Page" and not "Text" like target or "Url" like targetUrl --><br />
{{#set:Link targetPage={{{target|}}}}}<br />
<br />
<!-- display internal link with our without title --><br />
{{#if: {{{title|}}} <br />
| [[{{{target|Main Page}}}|{{{title}}}]] <br />
| [[{{{target|Main Page}}}]]<br />
}}<br />
}}<br />
<!-- set the Category so that any page using this is displayed in this category --><br />
[[Category:Link]]<br />
</source><br />
<br />
==== How the Link Macro works ====<br />
The Link Macro checks whether the link is external or internal and displays the correct version. It sets the Link Concept's attributes by setting the correspond Semantic Media Wiki properties.<br />
it uses the following helper funcitons:<br />
<br />
* Substring: https://www.mediawiki.org/wiki/Extension:StringFunctions/en#.23sub:<br />
* #ifeq: https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions/en#.23ifeq<br />
* #if: https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions/en#.23if<br />
* #set: https://semantic-mediawiki.org/wiki/Help:Setting_values<br />
===== Substring =====<br />
<pre><br />
{{#sub:string|start|length}}<br />
<br />
The start parameter, if positive (or zero), specifies a zero-based index of the first character to be returned.<br />
<br />
Example: {{#sub:Icecream|3}} returns cream.<br />
<br />
{{#sub:Icecream|0|3}} returns Ice.<br />
</pre><br />
<br />
===== if exists and non empty =====<br />
<pre><br />
{{#if: test string | value if test string is not empty | value if test string is empty (or only white space) }}<br />
</pre><br />
<br />
===== if equals =====<br />
<pre><br />
{{#ifeq: string 1 | string 2 | value if identical | value if different }}<br />
</pre><br />
===== setting Semantic values =====<br />
<pre><br />
{{#set:Has population=2,234,105<br />
|Located in country=France<br />
|Has mayor=Bertrand Delanoë<br />
}}<br />
</pre><br />
=== Properties set ===<br />
# {{Link|target=Property:Link_target}}<br />
# {{Link|target=Property:Link_targetPage}}<br />
# {{Link|target=Property:Link_targetUrl}}<br />
# {{Link|target=Property:Link_title}}<br />
[[Categorie:Link]]<br />
[[Category:Template]]</noinclude><includeonly>{{#set:Link target={{{target|}}}<br />
|Link title={{{title|}}}<br />
}}{{#ifeq: <br />
{{#sub:{{{target|}}}|0|4}} <br />
| http | {{#set:Link targetUrl={{{target|}}}}}{{#if: {{{title|}}} <br />
| [{{{target|http://www.smartMediaWiki.com}}} {{{title}}}] <br />
| [{{{target|http://www.smartMediaWiki.com}}}] <br />
}}| {{#set:Link targetPage={{{target|}}}}}{{#if: {{{title|}}} <br />
| [[{{{target|Main Page}}}|{{{title}}}]] <br />
| [[{{{target|Main Page}}}]]<br />
}}}}</includeonly></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1207Py-3rdparty-mediawiki2020-11-03T15:27:01Z<p>Wf: /* Prerequisites */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikuser script =<br />
This script is in the scripts directory. It should be linked with two names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
</source><br />
<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(readlink -nf $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
*)<br />
echo "undefined script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
= WikiUser =<br />
WikiUser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highligt='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the wikiuser script or Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1206Py-3rdparty-mediawiki2020-11-03T15:25:49Z<p>Wf: /* WikiPush */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikuser script =<br />
This script is in the scripts directory. It should be linked with two names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
</source><br />
<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(readlink -nf $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
*)<br />
echo "undefined script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
WikiPush allows to copy pages from one wiki to another including the images on the page.<br />
To identify yourself you use the credential property files created with the wikiuser script (using python) or the Mediawiki-Japi {{Link|target=CommandLine}}<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
= WikiUser =<br />
WikiUser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highligt='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1205Py-3rdparty-mediawiki2020-11-03T15:24:17Z<p>Wf: /* WikiUser */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikuser script =<br />
This script is in the scripts directory. It should be linked with two names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
</source><br />
<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(readlink -nf $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
*)<br />
echo "undefined script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
= WikiUser =<br />
WikiUser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
The credential file is compatible to the Java Mediawiki-Japi see {{Link|target=CommandLine#Credential_mode}}<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highligt='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1204Py-3rdparty-mediawiki2020-11-03T15:22:53Z<p>Wf: /* WikiUser */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikuser script =<br />
This script is in the scripts directory. It should be linked with two names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
</source><br />
<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(readlink -nf $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
*)<br />
echo "undefined script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
= WikiUser =<br />
WikiUser.py creates credential files and assigns a WikiId under which you can now operate. This simplifies access to your wiki.<br />
<br />
== usage ==<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
=== Example ===<br />
E.g. if you have an account on www.semantic-mediawiki.org you can start wikiuser in interactive mode.<br />
<br />
<source lang='bash' highligt='1'><br />
wikiuser<br />
email: john@doe.com<br />
scriptPath: /w<br />
user: jd<br />
url: http://www.semantic-mediawiki.org<br />
version: Mediawiki 1.33<br />
wikiId: smw<br />
password: *****<br />
shall i store jd smw? yes/no y/ny<br />
</source><br />
<br />
Now you can e.g. use "smw" as the wikiid for this wiki when using wikipush<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1203Py-3rdparty-mediawiki2020-11-03T15:17:43Z<p>Wf: /* WikiUser */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikuser script =<br />
This script is in the scripts directory. It should be linked with two names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
</source><br />
<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(readlink -nf $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
*)<br />
echo "undefined script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
= WikiUser =<br />
<source lang='bash'><br />
wikiuser -h<br />
usage: wikiuser.py [-h] [-d] [-V] [-e EMAIL] [-f FILEPATH] [-l URL]<br />
[-s SCRIPTPATH] [-p PASSWORD] [-u USER] [-v VERSION]<br />
[-w WIKIID] [-y]<br />
<br />
WikiUser credential handling<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-e EMAIL, --email EMAIL<br />
email of the user<br />
-f FILEPATH, --file FILEPATH<br />
ini-file path<br />
-l URL, --url URL url of the wiki<br />
-s SCRIPTPATH, --scriptPath SCRIPTPATH<br />
script path<br />
-p PASSWORD, --password PASSWORD<br />
password<br />
-u USER, --user USER os user id<br />
-v VERSION, --wikiVersion VERSION<br />
version of the wiki<br />
-w WIKIID, --wikiId WIKIID<br />
wiki Id<br />
-y, --yes immediately store without asking<br />
</source><br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1202Py-3rdparty-mediawiki2020-11-03T15:17:04Z<p>Wf: /* WikiPush */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikuser script =<br />
This script is in the scripts directory. It should be linked with two names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
</source><br />
<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(readlink -nf $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
*)<br />
echo "undefined script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
== usage ==<br />
<source lang='bash'><br />
wikipush -h<br />
family and mylang are not set.<br />
Defaulting to family='test' and mylang='test'.<br />
usage: wikipush.py [-h] [-d] [-V] [-l] [-f] [-i] [-q QUERY] -s SOURCE -t<br />
TARGET [-p PAGES [PAGES ...]]<br />
<br />
Created on 2020-10-29<br />
<br />
Created by Wolfgang Fahl on 2020-10-31.<br />
Copyright 2020 Wolfgang Fahl. All rights reserved.<br />
<br />
Licensed under the Apache License 2.0<br />
http://www.apache.org/licenses/LICENSE-2.0<br />
<br />
Distributed on an "AS IS" basis without warranties<br />
or conditions of any kind, either express or implied.<br />
<br />
USAGE<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-d, --debug set debug level [default: None]<br />
-V, --version show program's version number and exit<br />
-l, --login login to source wiki for access permission<br />
-f, --force force to overwrite existing pages<br />
-i, --ignore ignore upload warnings e.g. duplicate images<br />
-q QUERY, --query QUERY<br />
select pages with given SMW ask query<br />
-s SOURCE, --source SOURCE<br />
source wiki id<br />
-t TARGET, --target TARGET<br />
target wiki id<br />
-p PAGES [PAGES ...], --pages PAGES [PAGES ...]<br />
list of page Titles to be pushed<br />
</source><br />
<br />
= WikiUser =<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1201Py-3rdparty-mediawiki2020-11-03T15:16:23Z<p>Wf: /* wikipush / wikuser script */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikuser script =<br />
This script is in the scripts directory. It should be linked with two names<br />
<source lang='bash'><br />
ln wikipush wikiuser<br />
</source><br />
and be added to your path e.g by doing a symbolic link<br />
<source lang='bash'><br />
cd $HOME/bin<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikipush .<br />
ln -s $HOME/Documents/pyworkspace/py-3rdparty-mediawiki/scripts/wikiuser .<br />
</source><br />
<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(readlink -nf $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
*)<br />
echo "undefined script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
= WikiUser =<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1200Py-3rdparty-mediawiki2020-11-03T15:13:21Z<p>Wf: /* wikipush / wikuser script */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikuser script =<br />
This script is in the scripts directory<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(readlink -nf $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
*)<br />
echo "undefined script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
= WikiUser =<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1199Py-3rdparty-mediawiki2020-11-03T15:12:40Z<p>Wf: /* WikiPush */</p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= wikipush / wikuser script =<br />
<source lang='bash'><br />
#!/bin/bash<br />
# WF 2020-10-31<br />
# wrapper for wikipush python<br />
script=$(readlink -nf $BASH_SOURCE)<br />
scriptname=$(basename $script)<br />
scriptdir=$(dirname $script)<br />
base=$scriptdir/..<br />
export PYTHONPATH="${PYTHONPATH}:$base"<br />
case $scriptname in<br />
"wikipush")<br />
python -m wikibot.wikipush "$@"<br />
;;<br />
"wikiuser")<br />
python -m wikibot.wikiuser "$@"<br />
;;<br />
*)<br />
echo "undefined script behavior: $scriptname"<br />
;;<br />
esac<br />
</source><br />
<br />
= WikiPush =<br />
= WikiUser =<br />
<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Py-3rdparty-mediawiki&diff=1198Py-3rdparty-mediawiki2020-11-03T12:08:14Z<p>Wf: </p>
<hr />
<div>[https://gitter.im/Mediawiki-Japi/community Click here to comment]<br />
= What is it =<br />
Extended functionality for <br />
# pywikibot<br />
# mwclient<br />
<br />
= Github =<br />
* https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
<br />
= Installation =<br />
<source lang='bash'><br />
git clone https://github.com/WolfgangFahl/py-3rdparty-mediawiki<br />
./install<br />
</source><br />
<br />
= WikiPush =<br />
= Prerequisites =<br />
You might want to prepare some credential ini files with the Mediawiki-Japi [[CommandLine]].<br />
<br />
== user-config.py ==<br />
pywikibot expects a user-config.py file. The minimum recommended file for intranet usecases is:<br />
<source lang='python'><br />
# https://stackoverflow.com/a/60885381/1497139<br />
# Slow down the robot such that it never makes a second page edit within<br />
# 'put_throttle' seconds.<br />
put_throttle = 0<br />
</source><br />
The easiest way is to put it at $HOME/.pywikibot/user-config.py<br />
<br />
= Features =<br />
<br />
== Encrypted credential handling ==<br />
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.<br />
<br />
== Semantic MediaWiki API support ==<br />
see https://github.com/WolfgangFahl/py-3rdparty-mediawiki/issues/1<br />
<br />
== Example ==<br />
<source lang='python'><br />
from wikibot.wikibot import WikiBot<br />
wikibot=WikiBot.ofWikiId("test2")<br />
wikibot.site ...<br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Mediawiki_1.35_LTS&diff=1197Mediawiki 1.35 LTS2020-10-08T14:15:40Z<p>Wf: Created page with "<source lang='bash'> wget https://releases.wikimedia.org/mediawiki/1.35/mediawiki-1.35.0.tar.gz tar xvfz /usr/local/src/mediawiki-1.35.0.tar.gz </source>"</p>
<hr />
<div><source lang='bash'><br />
wget https://releases.wikimedia.org/mediawiki/1.35/mediawiki-1.35.0.tar.gz<br />
tar xvfz /usr/local/src/mediawiki-1.35.0.tar.gz <br />
</source></div>Wfhttp://mediawiki-japi.bitplan.com/index.php?title=Template:CurrentVersion&diff=1196Template:CurrentVersion2020-10-06T16:28:39Z<p>Wf: </p>
<hr />
<div><noinclude><br />
This is the current Version template<br />
see also [[Template:Download]]<br />
Please check that the current Version has also been changed at:<br />
* https://github.com/WolfgangFahl/Mediawiki-Japi (README.md)<br />
<br />
=== usage ===<br />
<pre>{{currentVersion}}</pre><br />
=== example ===<br />
{{currentVersion}}<br />
</noinclude><includeonly>0.1.06</includeonly></div>Wf