mwtp


Namemwtp JSON
Version 4.0.0 PyPI version JSON
download
home_page
SummaryA parser for MediaWiki titles
upload_time2024-02-23 06:17:33
maintainer
docs_urlNone
author
requires_python>=3.10
licenseGPL-3.0-only
keywords mediawiki title pagename parser
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # MediaWikiTitleParser

![Documentation status](https://readthedocs.org/projects/mwtp/badge/?version=latest)
![Tests](https://github.com/NguoiDungKhongDinhDanh/mwtp/actions/workflows/tests.yaml/badge.svg)
![License](https://img.shields.io/pypi/l/mwtp.svg)
![Supported versions](https://img.shields.io/pypi/pyversions/mwtp.svg)

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

It works as simple as follows:

```python
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][2] with
`action=query&meta=siteinfo&siprop=namespaces|namespacealiases`:

```python
namespaces_data = {
  '0': { 'id': 0, 'case': 'first-letter', 'name': '',          ...: ... },
  '1': { 'id': 1, 'case': 'first-letter', 'name': 'Thảo luận', ...: ... },
  ...: ...
}
```

```python
namespace_aliases = [
  { 'id': 1, 'alias': 'Foo' },
  ...
]
```

Note that the following format (`&formatversion=1`) is not supported.
Always use `&formatversion=2` or `&formatversion=latest`.

```python
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][3].


[1]: https://github.com/wikimedia/mediawiki/tree/c237f0548845662759bfcc6419cec9ca02d03c18/resources/src/mediawiki.Title
[2]: https://www.mediawiki.org/wiki/Special:ApiSandbox#action=query&meta=siteinfo&siprop=namespaces%7Cnamespacealiases
[3]: https://mwtp.readthedocs.io/

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "mwtp",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "mediawiki,title,pagename,parser",
    "author": "",
    "author_email": "NDKDD <adhominem259@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/61/1f/0a09bb4db39d3f39e39b6894fb008e99d0f77950ba573f79adaf9e5b7a75/mwtp-4.0.0.tar.gz",
    "platform": null,
    "description": "# MediaWikiTitleParser\n\n![Documentation status](https://readthedocs.org/projects/mwtp/badge/?version=latest)\n![Tests](https://github.com/NguoiDungKhongDinhDanh/mwtp/actions/workflows/tests.yaml/badge.svg)\n![License](https://img.shields.io/pypi/l/mwtp.svg)\n![Supported versions](https://img.shields.io/pypi/pyversions/mwtp.svg)\n\nMWTP is a parser for MediaWiki titles. Its logic is partly derived from\n[mediawiki.Title][1], and hence is licensed under GNU GPL.\n\nIt works as simple as follows:\n\n```python\nfrom mwtp import TitleParser as Parser\n\n\nparser = Parser(namespaces_data, namespace_aliases)\ntitle = parser.parse(' _ FoO: this/is A__/talk page _ ')\n\nprint(repr(title))\n# Title('Th\u1ea3o lu\u1eadn:This/is A /talk page')\n```\n\n`namespaces_data` and `namespace_aliases` can be obtained by\nmaking a query to [a wiki's API][2] with\n`action=query&meta=siteinfo&siprop=namespaces|namespacealiases`:\n\n```python\nnamespaces_data = {\n  '0': { 'id': 0, 'case': 'first-letter', 'name': '',          ...: ... },\n  '1': { 'id': 1, 'case': 'first-letter', 'name': 'Th\u1ea3o lu\u1eadn', ...: ... },\n  ...: ...\n}\n```\n\n```python\nnamespace_aliases = [\n  { 'id': 1, 'alias': 'Foo' },\n  ...\n]\n```\n\nNote that the following format (`&formatversion=1`) is not supported.\nAlways use `&formatversion=2` or `&formatversion=latest`.\n\n```python\nnamespaces_data = {\n  '0': { 'id': 0, 'case': 'first-letter', '*': '',          ...: ... },\n  '1': { 'id': 1, 'case': 'first-letter', '*': 'Th\u1ea3o lu\u1eadn', ...: ... },\n  ...: ...\n}\nnamespace_aliases = [\n  { 'id': 1, '*': 'Foo' },\n  ...\n]\n```\n\nFor more information, see [the documentation][3].\n\n\n[1]: https://github.com/wikimedia/mediawiki/tree/c237f0548845662759bfcc6419cec9ca02d03c18/resources/src/mediawiki.Title\n[2]: https://www.mediawiki.org/wiki/Special:ApiSandbox#action=query&meta=siteinfo&siprop=namespaces%7Cnamespacealiases\n[3]: https://mwtp.readthedocs.io/\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-only",
    "summary": "A parser for MediaWiki titles",
    "version": "4.0.0",
    "project_urls": {
        "Bug tracker": "https://github.com/NguoiDungKhongDinhDanh/mwtp/issues",
        "Documentation": "https://mwtp.readthedocs.io/",
        "Homepage": "https://github.com/NguoiDungKhongDinhDanh/mwtp"
    },
    "split_keywords": [
        "mediawiki",
        "title",
        "pagename",
        "parser"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7ccd85b0492f06a3d8e8617ec79133618c4f14eede40185c4650201491ecb91e",
                "md5": "82a9713904eb4233a82951646736ef6e",
                "sha256": "1a4f2f46074a44e30d028ce7d560a0d8e944e1c58d28d402271e078b66c72b80"
            },
            "downloads": -1,
            "filename": "mwtp-4.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "82a9713904eb4233a82951646736ef6e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 25722,
            "upload_time": "2024-02-23T06:17:31",
            "upload_time_iso_8601": "2024-02-23T06:17:31.586568Z",
            "url": "https://files.pythonhosted.org/packages/7c/cd/85b0492f06a3d8e8617ec79133618c4f14eede40185c4650201491ecb91e/mwtp-4.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "611f0a09bb4db39d3f39e39b6894fb008e99d0f77950ba573f79adaf9e5b7a75",
                "md5": "0f76f01fc18a47cbca6f36f164120d6c",
                "sha256": "70a6f978bbb052f9b18393cb1620dad642bb47066b915096a85351fe19c8b48f"
            },
            "downloads": -1,
            "filename": "mwtp-4.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0f76f01fc18a47cbca6f36f164120d6c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 29231,
            "upload_time": "2024-02-23T06:17:33",
            "upload_time_iso_8601": "2024-02-23T06:17:33.445962Z",
            "url": "https://files.pythonhosted.org/packages/61/1f/0a09bb4db39d3f39e39b6894fb008e99d0f77950ba573f79adaf9e5b7a75/mwtp-4.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-23 06:17:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NguoiDungKhongDinhDanh",
    "github_project": "mwtp",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "mwtp"
}
        
Elapsed time: 0.24073s