Py-3rdparty-mediawiki

From BITPlan Wiki
Jump to navigation Jump to search

OsProject

OsProject
edit
id  Py-3rdparty-mediawiki
state  active
owner  WolfgangFahl
title  Py-3rdparty-mediawiki (Wikipush Toolkit)
url  https://github.com/WolfgangFahl/py-3rdparty-mediawiki
version  0.19.5
description  Python 3rd party Mediawiki bot support - also known as the Wikipush Toolkit - automating MediaWiki page content handling for any wiki, SMW or non-SMW, by faking SMW-style queries for categories
date  2026-03-31
since  2020-03-26
until  

About

py-3rdparty-mediawiki is also known as the Wikipush Toolkit — a set of tools for automating MediaWiki page content handling using Python and a command line. This project was presented at SMWCon Fall 2020.

The toolkit works with any MediaWiki wiki, not just SMW-enabled ones: SMW wikis are queried natively using ask queries, while non-SMW wikis are supported by faking SMW-style queries for categories — allowing pages to be pushed from wikis without Semantic MediaWiki installed.

Examples

wikipush

Copy pages between wikis:

wikipush -s smw -t test2 -q "[[Category:City]]|limit=5"
copying 4 pages from smw to test2
copying Demo:Tokyo ...✅
copying image File:SMW-Info-button.png ...✅
copying image File:Tokyo-Tsukishima-0011.jpg ...✅
copying Vienna ...✅
copying Warsaw ...✅
copying image File:6140285934 02e81b845f z.jpg ...✅
copying Demo:Würzburg ...✅

wikiupload

Upload files to a wiki:

wikiupload -t test --files car.png
uploading 1 files to test
1/1 ( 100%): uploading car.png ...✅

wikinuke

The default behavior is a dry run only listing whether the pages exist:

wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3
deleting 3 pages in test (dry run)
1/3 (  33%): deleting deleteMe1 ...👍
2/3 (  67%): deleting deleteMe2 ...👍
3/3 ( 100%): deleting deleteMe3 ...👍

After checking you might want to (carefully) use the "-f" option to actually force the deletion:

wikinuke -t test -p deleteMe1 deleteMe2 deleteMe3 -f
deleting 3 pages in test (forced)
1/3 (  33%): deleting deleteMe1 ...✅
2/3 (  67%): deleting deleteMe2 ...✅
3/3 ( 100%): deleting deleteMe3 ...✅

wikiedit

wikiedit -t test -q "[[isA::CFP]]" --search "CALL FOR PAPER" --replace "CFP"
editing 1 pages in test (dry run)
1/1 ( 100%): editing CALL FOR PAPER Journal: Advances in Multimedia - An International Journal (AMIJ) ...👍

wikiuser

Configure wiki credentials interactively:

wikiuser
email: john@doe.com
scriptPath: /w
user: jd
url: http://www.semantic-mediawiki.org
version: Mediawiki 1.33
wikiId: smw
password: ****
shall i store jd smw? yes/no y/n

Links