Skip to main content

MediaWiki template parser and editor

Project description

https://travis-ci.org/danmichaelo/mwtemplates.png?branch=master https://coveralls.io/repos/danmichaelo/mwtemplates/badge.png

mwtemplates is a simple wikitext template parser and editor, based on a python rewrite of the mediawiki preprocessorDOM.php. Tested with python 2.6, 2.7, 3.2 and 3.3.

It can be installed directly off github:

$ pip install git+git://github.com/danmichaelo/mwtemplates.git

(There is also a version on PyPi that can be installed using pip install mwtemplates or easy_install mwtemplates)

Running tests

To run tests, clone the repo and do:

$ pip install -r requirements.txt
$ pip install -r test_requirements.txt
$ py.test -x tests --pep8 mwtemplates -v --cov mwtemplates --doctest-modules

Usage examples

Usage example:

from mwtemplates import TemplateEditor
txt = u"""
{{Infoboks geografi
| kart = Svalbard_kart1.png
| land = Norge
| status = Øygruppe
| administrasjon = [[Odd Olsen Ingerø]] ''<small>(2009)</small>''
| administrasjonsnavn = [[Sysselmannen på Svalbard|Sysselmann]]
| areal = 61022
| befolkning = 2527
| befolkningsår = [[2011]]
| url = www.sysselmannen.svalbard.no
}}
"""
te = TemplateEditor(txt)
te.templates['infoboks geografi'][0].parameters['land'] = 'Russland'
print te.wikitext()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mwtemplates-0.2.tar.gz (14.5 kB view details)

Uploaded Source

File details

Details for the file mwtemplates-0.2.tar.gz.

File metadata

  • Download URL: mwtemplates-0.2.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mwtemplates-0.2.tar.gz
Algorithm Hash digest
SHA256 358771321ff897134862f1960c242bfac5d150310942462f0841aae22dd125ec
MD5 473bd6320a104d8250865641c4bded34
BLAKE2b-256 78de2a507d1b613fb4fbe536236647a3117bae55c61d8a0c3f7bdbf30f49e252

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page