Skip to main content

A set of types for processing MediaWiki data.

Project description

# MediaWiki Types

This library provides a set of classes for working with MediaWiki data types. The point of this library is to help standardize different schemes and naming patterns between the database, XML dumps and API responses.

  • Installation: pip install mwtypes

## Types

  • Contributor – An ‘id’ and ‘user_text’ of a user

  • Deleted – The deleted/suppressed status of a revision or event

  • Namespace – Namespace ID and metadata (‘aliases’, ‘canonical’, ‘content’)

  • Page – Metadata about a page (‘id’, ‘title’, ‘namespace’, ‘restrictions’, etc.)

  • Revision – Metadata about a revision (‘id’, ‘contributor’, ‘timestamp’, etc.)

  • Timestamp – Basic operations and formatting of MediaWiki timestamp formats

## Timestamp example

>>> import datetime, time
>>> from mwtypes import Timestamp
>>> Timestamp(1234567890)
Timestamp('2009-02-13T23:31:30Z')
>>> Timestamp(1234567890) == Timestamp("2009-02-13T23:31:30Z")
True
>>> Timestamp(1234567890) == Timestamp("20090213233130")
True
>>> Timestamp(1234567890) == Timestamp(datetime.datetime.utcfromtimestamp(1234567890))
True
>>> Timestamp(1234567890) == Timestamp(time.strptime("2009-02-13T23:31:30Z", "%Y-%m-%dT%H:%M:%SZ"))
True
>>> Timestamp(1234567890) == Timestamp(Timestamp(1234567890))
True

You can also do math and comparisons of timestamps.:

>>> from mwtypes import Timestamp
>>> t = Timestamp(1234567890)
>>> t
Timestamp('2009-02-13T23:31:30Z')
>>> t2 = t + 10
>>> t2
Timestamp('2009-02-13T23:31:40Z')
>>> t += 1
>>> t
Timestamp('2009-02-13T23:31:31Z')
>>> t2 - t
9
>>> t < t2
True

Project details


Download files

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

Source Distributions

mwtypes-0.1.0.zip (12.7 kB view hashes)

Uploaded Source

mwtypes-0.1.0.tar.gz (8.7 kB view hashes)

Uploaded Source

Built Distribution

mwtypes-0.1.0-py3.4.egg (26.6 kB view hashes)

Uploaded Source

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