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 obtained by
making a query to a wiki's API with
action=query&meta=siteinfo&siprop=namespaces|namespacealiases:
namespaces_data = {
'0': { 'id': 0, 'case': 'first-letter', 'name': '', ...: ... },
'1': { 'id': 1, 'case': 'first-letter', 'name': 'Thảo luận', ...: ... },
...: ...
}
namespace_aliases = [
{ 'id': 1, 'alias': 'Foo' },
...
]
Note that the following format (&formatversion=1) is not supported.
Always use &formatversion=2 or &formatversion=latest.
namespaces_data = {
'0': { 'id': 0, 'case': 'first-letter', '*': '', ...: ... },
'1': { 'id': 1, 'case': 'first-letter', '*': 'Thảo luận', ...: ... },
...: ...
}
namespace_aliases = [
{ 'id': 1, '*': 'Foo' },
...
]
For more information, see the documentation.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mwtp-4.0.0.tar.gz.
File metadata
- Download URL: mwtp-4.0.0.tar.gz
- Upload date:
- Size: 29.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70a6f978bbb052f9b18393cb1620dad642bb47066b915096a85351fe19c8b48f
|
|
| MD5 |
0f76f01fc18a47cbca6f36f164120d6c
|
|
| BLAKE2b-256 |
611f0a09bb4db39d3f39e39b6894fb008e99d0f77950ba573f79adaf9e5b7a75
|
File details
Details for the file mwtp-4.0.0-py3-none-any.whl.
File metadata
- Download URL: mwtp-4.0.0-py3-none-any.whl
- Upload date:
- Size: 25.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a4f2f46074a44e30d028ce7d560a0d8e944e1c58d28d402271e078b66c72b80
|
|
| MD5 |
82a9713904eb4233a82951646736ef6e
|
|
| BLAKE2b-256 |
7ccd85b0492f06a3d8e8617ec79133618c4f14eede40185c4650201491ecb91e
|