Skip to main content

A parser for MediaWiki titles

Project description

MediaWikiTitleParser

Tests

MWTP is a parser for MediaWiki titles. Its logic is partly derived from mediawiki.Title, and hence is licensed under GNU GPL.

It works as simple as follows:

from mwtp import TitleParser as Parser


parser = Parser(namespaces_data, namespace_aliases)
title = parser.parse(' _ FoO: this/is A__/talk page _ ')

print(title)
# Title(title = 'This/is A /talk page', namespace = 1)

namespaces_data and namespace_aliases can be queried directly from a wiki's API using action=query&meta=siteinfo&siprop=namespaces|namespacealiases:

namespaces_data = {
  '0': {
    'id': 0,
    'case': 'first-letter',
    'name': '',
    'subpages': False,
    'content': True,
    'nonincludable': False
  },
  '1': {
    'id': 1,
    'case': 'first-letter',
    'name': 'Thảo luận',
    'subpages': True,
    'canonical': 'Talk',
    'content': False,
    'nonincludable': False
  },
  ...: ...
}
namespace_aliases = [
  { 'id': 1, 'alias': 'Foo' },
  ...
]

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

mwtp-1.0.1.tar.gz (50.1 kB view details)

Uploaded Source

Built Distribution

mwtp-1.0.1-py3-none-any.whl (34.3 kB view details)

Uploaded Python 3

File details

Details for the file mwtp-1.0.1.tar.gz.

File metadata

  • Download URL: mwtp-1.0.1.tar.gz
  • Upload date:
  • Size: 50.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0b4

File hashes

Hashes for mwtp-1.0.1.tar.gz
Algorithm Hash digest
SHA256 ee37ecb0913d3e3fd0860125faaf5d9b9bfad66ac93cddd5b0636970f1905324
MD5 20f1da028958e9bdd1fc9911fd198621
BLAKE2b-256 059c11adb0ba2addaa2c7e93296f12700c7b81cf52440bea929d6a6609a015c6

See more details on using hashes here.

Provenance

File details

Details for the file mwtp-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: mwtp-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 34.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0b4

File hashes

Hashes for mwtp-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cd67ae41500692d18f53c05fde0e5eea23788d5bba560ebf3fe6c8f8ee95bd9c
MD5 34fb36ca78aff708d3f373b9dd902ea6
BLAKE2b-256 e37d4956172dd00c45b9ba052a81fd320e5cd75db44c1d353d99d9293da716a0

See more details on using hashes here.

Provenance

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