A parser for MediaWiki titles
Project description
MediaWikiTitleParser
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(repr(title))
# Title('Thảo luận:This/is A /talk page')
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
Release history Release notifications | RSS feed
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.3.tar.gz
(50.1 kB
view details)
Built Distribution
mwtp-1.0.3-py3-none-any.whl
(34.3 kB
view details)
File details
Details for the file mwtp-1.0.3.tar.gz
.
File metadata
- Download URL: mwtp-1.0.3.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | e27958580e103063e882f2de3be4d8761c2dbd7f27d4e7377d72e0a9d9359450 |
|
MD5 | 70cddd7e9c0be638aa47a1f43ff8611d |
|
BLAKE2b-256 | 8e8ffc3dd56cbb34cc9b23ddea1849e00ebf4309035e5b04a1043958568de383 |
Provenance
File details
Details for the file mwtp-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: mwtp-1.0.3-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | f115ac898ec6e18fe8aa1727283858e4bf74c5988b3b81a2a129422333769700 |
|
MD5 | 96ddf89dba2c1ab08f8fdf579c47e377 |
|
BLAKE2b-256 | 1e24661330e846dfb5303279c420bd1febddff0d76a86c74b063fa3f1dc85f5d |