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(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
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.2.tar.gz
(50.0 kB
view hashes)
Built Distribution
mwtp-1.0.2-py3-none-any.whl
(34.3 kB
view hashes)