mwtypes

raw JSON →
0.4.0 verified Fri May 01 auth: no python maintenance

A set of types for processing MediaWiki data. Provides data structures for MediaWiki XML dumps, revisions, and page metadata. Latest version 0.4.0, low release cadence (last release 2019).

pip install mwtypes
error ImportError: No module named 'mwtypes'
cause mwtypes not installed or environment issue.
fix
Run pip install mwtypes.
error AttributeError: 'Page' object has no attribute 'revisions'
cause Revisions are stored under `page.revisions` but may be missing if page has no revisions.
fix
Check page.revisions is not None before accessing.
gotcha mwtypes is a low-level library; most users should use mwxml or mwcli for XML dump parsing.
fix Use `mwxml` for iterating over dump files.
gotcha Fields may be None if not present; always check for None before accessing nested attributes.
fix Always validate attributes like `page.namespace` before use.

Basic usage creating a Page with a Revision.

from mwtypes import Page, Revision

# Create a simple page object
page = Page(
    id=123,
    title='Test Page',
    namespace=0,
    revisions=[Revision(id=1, text='Hello World')]
)
print(page.title)