Wikipedia-API 0.14.1__tar.gz → 0.16.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/.gitignore +2 -1
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/CHANGES.rst +14 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/DESIGN.rst +4 -0
- wikipedia_api-0.16.0/DEVELOPMENT.rst +86 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/PKG-INFO +30 -5
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/README.rst +27 -2
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/README_processed.rst +27 -2
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/examples/example_async.py +1 -1
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/examples/example_cli.sh +1 -1
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/examples/example_sync.py +1 -1
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/pyproject.toml +16 -17
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_http_client/async_http_client.py +3 -1
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_http_client/base_http_client.py +7 -2
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_http_client/sync_http_client.py +3 -1
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_version.py +1 -1
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_wikipedia/async_wikipedia.py +2 -1
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_wikipedia/wikipedia.py +2 -1
- wikipedia_api-0.14.1/DEVELOPMENT.rst +0 -47
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/API.rst +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/CLI.rst +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/LICENSE +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/SKILLS/README.md +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/SKILLS/bash.md +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/SKILLS/python-async.md +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/SKILLS/python-sync.md +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/__init__.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_enums/__init__.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_enums/coordinate_type.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_enums/coordinates_prop.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_enums/direction.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_enums/geosearch_sort.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_enums/globe.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_enums/namespace.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_enums/redirect_filter.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_enums/search_info.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_enums/search_prop.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_enums/search_qi_profile.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_enums/search_sort.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_enums/search_what.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_http_client/__init__.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_http_client/retry_after_wait.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_http_client/retry_utils.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_image/__init__.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_image/_base_wikipedia_image.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_image/async_wikipedia_image.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_image/wikipedia_image.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_page/__init__.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_page/_base_wikipedia_page.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_page/async_wikipedia_page.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_page/wikipedia_page.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_page/wikipedia_page_section.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_pages_dict/__init__.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_pages_dict/async_images_dict.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_pages_dict/async_pages_dict.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_pages_dict/base_pages_dict.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_pages_dict/images_dict.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_pages_dict/pages_dict.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_params/__init__.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_params/base_params.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_params/coordinates_params.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_params/geo_search_params.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_params/imageinfo_params.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_params/images_params.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_params/protocols.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_params/random_params.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_params/search_params.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_resources/__init__.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_resources/async_wikipedia_resource.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_resources/base_wikipedia_resource.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_resources/wikipedia_resource.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_types/__init__.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_types/coordinate.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_types/geo_box.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_types/geo_point.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_types/geo_search_meta.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_types/image_info.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_types/search_meta.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_types/search_results.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_wikipedia/__init__.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/cli.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/commands/__init__.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/commands/base.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/commands/category_commands.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/commands/geo_commands.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/commands/image_commands.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/commands/link_commands.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/commands/page_commands.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/commands/search_commands.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/exceptions/__init__.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/exceptions/wiki_connection_error.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/exceptions/wiki_http_error.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/exceptions/wiki_http_timeout_error.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/exceptions/wiki_invalid_json_error.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/exceptions/wiki_rate_limit_error.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/exceptions/wikipedia_exception.py +0 -0
- {wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/extract_format.py +0 -0
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
0.16.0
|
|
5
|
+
----------
|
|
6
|
+
|
|
7
|
+
* Allow passing a custom ``transport`` to the underlying ``httpx`` client (e.g. a caching transport such as Hishel) - `PR 659`_
|
|
8
|
+
|
|
9
|
+
.. _PR 659: https://github.com/martin-majlis/Wikipedia-API/pull/659
|
|
10
|
+
|
|
11
|
+
0.15.0
|
|
12
|
+
----------
|
|
13
|
+
|
|
14
|
+
* Make user agent header compliant with Wikimedia Foundation User-Agent policy - `PR 590`_
|
|
15
|
+
|
|
16
|
+
.. _PR 590: https://github.com/martin-majlis/Wikipedia-API/pull/590
|
|
17
|
+
|
|
4
18
|
0.14.1
|
|
5
19
|
------
|
|
6
20
|
|
|
@@ -317,6 +317,8 @@ SyncHTTPClient
|
|
|
317
317
|
Provides a blocking ``_get(language, params) -> dict`` method in ``sync_http_client.py`` backed by
|
|
318
318
|
``httpx.Client``. Retry logic uses ``tenacity`` with exponential
|
|
319
319
|
backoff; ``Retry-After`` headers are honoured for HTTP 429 responses.
|
|
320
|
+
The client defaults to ``httpx.HTTPTransport`` but honours a caller-supplied
|
|
321
|
+
``transport`` kwarg (e.g. a caching transport).
|
|
320
322
|
|
|
321
323
|
AsyncHTTPClient
|
|
322
324
|
~~~~~~~~~~~~~~~
|
|
@@ -324,6 +326,8 @@ AsyncHTTPClient
|
|
|
324
326
|
Provides an ``async def _get(language, params) -> dict`` coroutine in ``async_http_client.py``
|
|
325
327
|
backed by ``httpx.AsyncClient``. Retry logic mirrors
|
|
326
328
|
``SyncHTTPClient`` but uses ``tenacity``'s ``AsyncRetrying``.
|
|
329
|
+
The client defaults to ``httpx.AsyncHTTPTransport`` but honours a caller-supplied
|
|
330
|
+
``transport`` kwarg.
|
|
327
331
|
|
|
328
332
|
Both clients construct the endpoint URL as::
|
|
329
333
|
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
Development
|
|
2
|
+
===========
|
|
3
|
+
|
|
4
|
+
Prerequisites
|
|
5
|
+
--------------
|
|
6
|
+
|
|
7
|
+
* Make
|
|
8
|
+
* Python 3.10+
|
|
9
|
+
* Pip
|
|
10
|
+
|
|
11
|
+
Makefile targets
|
|
12
|
+
-----------------
|
|
13
|
+
* ``make run-type-check`` - type checks source code (runs ``uv run ty check wikipediaapi/``)
|
|
14
|
+
* ``make run-ruff`` - lints and checks formatting (runs ``ruff check`` and ``ruff format --check``)
|
|
15
|
+
* ``make requirements-all`` - install all requirements
|
|
16
|
+
* ``make requirements`` - install package requirements
|
|
17
|
+
* ``make requirements-dev`` - install development requirements
|
|
18
|
+
* ``make run-tests`` - run unit tests (pytest)
|
|
19
|
+
* ``make run-tests-integration`` - run VCR integration tests (pytest)
|
|
20
|
+
* ``make run-coverage`` - run code coverage (pytest-cov)
|
|
21
|
+
* ``make pypi-html`` - generates single HTML documentation into ``pypi-doc.html``
|
|
22
|
+
* ``make html`` - generates HTML documentation similar to RTFD into folder ``_build/html/``
|
|
23
|
+
* ``make prepare-release VERSION='1.2.3'`` - bumps version files, runs full pre-release checks, and opens a PR from a ``release/1.2.3`` branch
|
|
24
|
+
* ``make create-github-release VERSION='1.2.3'`` - after the PR is merged, creates a GitHub Release with auto-generated notes, triggering PyPI publish
|
|
25
|
+
|
|
26
|
+
Releasing a New Version
|
|
27
|
+
-----------------------
|
|
28
|
+
|
|
29
|
+
**During development** — as each PR is merged, add a bullet point describing the
|
|
30
|
+
change under the ``Unreleased`` section at the top of ``CHANGES.rst``::
|
|
31
|
+
|
|
32
|
+
Unreleased
|
|
33
|
+
----------
|
|
34
|
+
|
|
35
|
+
* Add support for foo - `PR 123`_
|
|
36
|
+
|
|
37
|
+
.. _PR 123: https://github.com/martin-majlis/Wikipedia-API/pull/123
|
|
38
|
+
|
|
39
|
+
**When ready to release:**
|
|
40
|
+
|
|
41
|
+
1. From a clean ``master`` branch, run::
|
|
42
|
+
|
|
43
|
+
make prepare-release VERSION='1.2.3'
|
|
44
|
+
|
|
45
|
+
This will:
|
|
46
|
+
|
|
47
|
+
* Validate the version format and that it is greater than the current version
|
|
48
|
+
* Check that ``CHANGES.rst`` has an ``Unreleased`` section
|
|
49
|
+
* Run the full pre-release check suite (tests, type checks, linting, examples)
|
|
50
|
+
* Create a ``release/1.2.3`` branch
|
|
51
|
+
* Rename ``Unreleased`` → ``1.2.3`` in ``CHANGES.rst`` and bump all version files
|
|
52
|
+
* Commit, push the branch, and open a pull request
|
|
53
|
+
|
|
54
|
+
2. Review and merge the pull request.
|
|
55
|
+
|
|
56
|
+
3. After the PR is merged, create the GitHub Release::
|
|
57
|
+
|
|
58
|
+
make create-github-release VERSION='1.2.3'
|
|
59
|
+
|
|
60
|
+
This creates a ``v1.2.3`` tag and GitHub Release with auto-generated release
|
|
61
|
+
notes (based on merged PRs since the last release), which triggers the
|
|
62
|
+
``release.yml`` workflow to publish the package to PyPI.
|
|
63
|
+
|
|
64
|
+
Usage Statistics
|
|
65
|
+
----------------
|
|
66
|
+
|
|
67
|
+
* `PIP Downloads`_
|
|
68
|
+
* `Clickpy`_
|
|
69
|
+
* `Libraries.io`_
|
|
70
|
+
* `Deps.dev`_
|
|
71
|
+
|
|
72
|
+
.. _PIP Downloads: https://pypistats.org/packages/wikipedia-api
|
|
73
|
+
.. _Libraries.io: https://libraries.io/pypi/Wikipedia-API
|
|
74
|
+
.. _Deps.dev: https://deps.dev/pypi/wikipedia-api
|
|
75
|
+
.. _Clickpy: https://clickpy.clickhouse.com/dashboard/wikipedia-api
|
|
76
|
+
|
|
77
|
+
Underlying API
|
|
78
|
+
--------------
|
|
79
|
+
|
|
80
|
+
* `API - HP`_
|
|
81
|
+
* `Module - Parse`_
|
|
82
|
+
* `Module - Query`_
|
|
83
|
+
|
|
84
|
+
.. _API - HP: https://www.mediawiki.org/wiki/API:Main_page
|
|
85
|
+
.. _Module - Parse: https://en.wikipedia.org/w/api.php?action=help&modules=parse
|
|
86
|
+
.. _Module - Query: https://en.wikipedia.org/w/api.php?action=help&modules=query
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: Wikipedia-API
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.16.0
|
|
4
4
|
Summary: Python Wrapper for Wikipedia
|
|
5
5
|
Project-URL: Homepage, https://github.com/martin-majlis/Wikipedia-API
|
|
6
6
|
Project-URL: Repository, https://github.com/martin-majlis/Wikipedia-API
|
|
@@ -26,7 +26,7 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
|
26
26
|
Classifier: Topic :: Communications :: Email
|
|
27
27
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
28
28
|
Requires-Python: >=3.10
|
|
29
|
-
Requires-Dist: click==8.
|
|
29
|
+
Requires-Dist: click==8.5.0
|
|
30
30
|
Requires-Dist: httpx==0.28.1
|
|
31
31
|
Requires-Dist: tenacity==9.1.4
|
|
32
32
|
Description-Content-Type: text/x-rst
|
|
@@ -89,10 +89,10 @@ Getting single page is straightforward. You have to initialize ``Wikipedia`` (or
|
|
|
89
89
|
object and ask for page by its name.
|
|
90
90
|
To initialize it, you have to provide:
|
|
91
91
|
|
|
92
|
-
* `user_agent` to identify your project.
|
|
92
|
+
* `user_agent` to identify your project. **Must include contact information** (email or website) and follow the Wikimedia Foundation `User-Agent policy`_.
|
|
93
93
|
* `language` to specify language mutation. It has to be one of `supported languages`_.
|
|
94
94
|
|
|
95
|
-
..
|
|
95
|
+
.. _User-Agent policy: https://foundation.wikimedia.org/wiki/Policy:Wikimedia_Foundation_User-Agent_Policy
|
|
96
96
|
.. _supported languages: http://meta.wikimedia.org/wiki/List_of_Wikipedias
|
|
97
97
|
|
|
98
98
|
**Synchronous**
|
|
@@ -1045,6 +1045,31 @@ The same options apply to both ``Wikipedia`` and ``AsyncWikipedia``.
|
|
|
1045
1045
|
max_retries=0,
|
|
1046
1046
|
)
|
|
1047
1047
|
|
|
1048
|
+
Custom HTTP Transport
|
|
1049
|
+
~~~~~~~~~~~~~~~~~~~~~~
|
|
1050
|
+
|
|
1051
|
+
Any keyword argument that is not recognised by ``Wikipedia`` / ``AsyncWikipedia`` is
|
|
1052
|
+
forwarded to the underlying ``httpx`` client. This includes ``transport``, which lets you
|
|
1053
|
+
plug in a custom transport such as a caching transport
|
|
1054
|
+
(e.g. `Hishel <https://hishel.com/httpx.html>`_). When ``transport`` is omitted, the default
|
|
1055
|
+
``httpx.HTTPTransport`` (sync) / ``httpx.AsyncHTTPTransport`` (async) is used.
|
|
1056
|
+
|
|
1057
|
+
.. code-block:: python
|
|
1058
|
+
|
|
1059
|
+
import hishel
|
|
1060
|
+
import httpx
|
|
1061
|
+
import wikipediaapi
|
|
1062
|
+
|
|
1063
|
+
# Cache responses so repeated lookups avoid hitting Wikipedia again
|
|
1064
|
+
wiki_wiki = wikipediaapi.Wikipedia(
|
|
1065
|
+
user_agent='MyProjectName (merlin@example.com)',
|
|
1066
|
+
language='en',
|
|
1067
|
+
transport=hishel.CacheTransport(transport=httpx.HTTPTransport()),
|
|
1068
|
+
)
|
|
1069
|
+
|
|
1070
|
+
For ``AsyncWikipedia`` use an async transport (e.g.
|
|
1071
|
+
``hishel.AsyncCacheTransport(transport=httpx.AsyncHTTPTransport())``).
|
|
1072
|
+
|
|
1048
1073
|
How To See Underlying API Call
|
|
1049
1074
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
1050
1075
|
|
|
@@ -56,10 +56,10 @@ Getting single page is straightforward. You have to initialize ``Wikipedia`` (or
|
|
|
56
56
|
object and ask for page by its name.
|
|
57
57
|
To initialize it, you have to provide:
|
|
58
58
|
|
|
59
|
-
* `user_agent` to identify your project.
|
|
59
|
+
* `user_agent` to identify your project. **Must include contact information** (email or website) and follow the Wikimedia Foundation `User-Agent policy`_.
|
|
60
60
|
* `language` to specify language mutation. It has to be one of `supported languages`_.
|
|
61
61
|
|
|
62
|
-
..
|
|
62
|
+
.. _User-Agent policy: https://foundation.wikimedia.org/wiki/Policy:Wikimedia_Foundation_User-Agent_Policy
|
|
63
63
|
.. _supported languages: http://meta.wikimedia.org/wiki/List_of_Wikipedias
|
|
64
64
|
|
|
65
65
|
**Synchronous**
|
|
@@ -1012,6 +1012,31 @@ The same options apply to both ``Wikipedia`` and ``AsyncWikipedia``.
|
|
|
1012
1012
|
max_retries=0,
|
|
1013
1013
|
)
|
|
1014
1014
|
|
|
1015
|
+
Custom HTTP Transport
|
|
1016
|
+
~~~~~~~~~~~~~~~~~~~~~~
|
|
1017
|
+
|
|
1018
|
+
Any keyword argument that is not recognised by ``Wikipedia`` / ``AsyncWikipedia`` is
|
|
1019
|
+
forwarded to the underlying ``httpx`` client. This includes ``transport``, which lets you
|
|
1020
|
+
plug in a custom transport such as a caching transport
|
|
1021
|
+
(e.g. `Hishel <https://hishel.com/httpx.html>`_). When ``transport`` is omitted, the default
|
|
1022
|
+
``httpx.HTTPTransport`` (sync) / ``httpx.AsyncHTTPTransport`` (async) is used.
|
|
1023
|
+
|
|
1024
|
+
.. code-block:: python
|
|
1025
|
+
|
|
1026
|
+
import hishel
|
|
1027
|
+
import httpx
|
|
1028
|
+
import wikipediaapi
|
|
1029
|
+
|
|
1030
|
+
# Cache responses so repeated lookups avoid hitting Wikipedia again
|
|
1031
|
+
wiki_wiki = wikipediaapi.Wikipedia(
|
|
1032
|
+
user_agent='MyProjectName (merlin@example.com)',
|
|
1033
|
+
language='en',
|
|
1034
|
+
transport=hishel.CacheTransport(transport=httpx.HTTPTransport()),
|
|
1035
|
+
)
|
|
1036
|
+
|
|
1037
|
+
For ``AsyncWikipedia`` use an async transport (e.g.
|
|
1038
|
+
``hishel.AsyncCacheTransport(transport=httpx.AsyncHTTPTransport())``).
|
|
1039
|
+
|
|
1015
1040
|
How To See Underlying API Call
|
|
1016
1041
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
1017
1042
|
|
|
@@ -56,10 +56,10 @@ Getting single page is straightforward. You have to initialize ``Wikipedia`` (or
|
|
|
56
56
|
object and ask for page by its name.
|
|
57
57
|
To initialize it, you have to provide:
|
|
58
58
|
|
|
59
|
-
* `user_agent` to identify your project.
|
|
59
|
+
* `user_agent` to identify your project. **Must include contact information** (email or website) and follow the Wikimedia Foundation `User-Agent policy`_.
|
|
60
60
|
* `language` to specify language mutation. It has to be one of `supported languages`_.
|
|
61
61
|
|
|
62
|
-
..
|
|
62
|
+
.. _User-Agent policy: https://foundation.wikimedia.org/wiki/Policy:Wikimedia_Foundation_User-Agent_Policy
|
|
63
63
|
.. _supported languages: http://meta.wikimedia.org/wiki/List_of_Wikipedias
|
|
64
64
|
|
|
65
65
|
**Synchronous**
|
|
@@ -1012,6 +1012,31 @@ The same options apply to both ``Wikipedia`` and ``AsyncWikipedia``.
|
|
|
1012
1012
|
max_retries=0,
|
|
1013
1013
|
)
|
|
1014
1014
|
|
|
1015
|
+
Custom HTTP Transport
|
|
1016
|
+
~~~~~~~~~~~~~~~~~~~~~~
|
|
1017
|
+
|
|
1018
|
+
Any keyword argument that is not recognised by ``Wikipedia`` / ``AsyncWikipedia`` is
|
|
1019
|
+
forwarded to the underlying ``httpx`` client. This includes ``transport``, which lets you
|
|
1020
|
+
plug in a custom transport such as a caching transport
|
|
1021
|
+
(e.g. `Hishel <https://hishel.com/httpx.html>`_). When ``transport`` is omitted, the default
|
|
1022
|
+
``httpx.HTTPTransport`` (sync) / ``httpx.AsyncHTTPTransport`` (async) is used.
|
|
1023
|
+
|
|
1024
|
+
.. code-block:: python
|
|
1025
|
+
|
|
1026
|
+
import hishel
|
|
1027
|
+
import httpx
|
|
1028
|
+
import wikipediaapi
|
|
1029
|
+
|
|
1030
|
+
# Cache responses so repeated lookups avoid hitting Wikipedia again
|
|
1031
|
+
wiki_wiki = wikipediaapi.Wikipedia(
|
|
1032
|
+
user_agent='MyProjectName (merlin@example.com)',
|
|
1033
|
+
language='en',
|
|
1034
|
+
transport=hishel.CacheTransport(transport=httpx.HTTPTransport()),
|
|
1035
|
+
)
|
|
1036
|
+
|
|
1037
|
+
For ``AsyncWikipedia`` use an async transport (e.g.
|
|
1038
|
+
``hishel.AsyncCacheTransport(transport=httpx.AsyncHTTPTransport())``).
|
|
1039
|
+
|
|
1015
1040
|
How To See Underlying API Call
|
|
1016
1041
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
1017
1042
|
|
|
@@ -28,7 +28,7 @@ from wikipediaapi import coordinates_prop2str
|
|
|
28
28
|
# Set to INFO to see the actual API request URLs being made
|
|
29
29
|
logging.basicConfig(level=logging.WARNING)
|
|
30
30
|
|
|
31
|
-
user_agent = "
|
|
31
|
+
user_agent = "MyCoolBot/1.0 (myemail@example.com)"
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
def print_sections(sections, level=0):
|
|
@@ -19,7 +19,7 @@ from wikipediaapi import coordinates_prop2str
|
|
|
19
19
|
# Set to INFO to see the actual API request URLs being made
|
|
20
20
|
logging.basicConfig(level=logging.WARNING)
|
|
21
21
|
|
|
22
|
-
user_agent = "
|
|
22
|
+
user_agent = "MyCoolBot/1.0 (myemail@example.com)"
|
|
23
23
|
|
|
24
24
|
# ──────────────────────────────────────────────────────────────────────────────
|
|
25
25
|
# 1. Creating a Wikipedia client
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "Wikipedia-API"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.16.0"
|
|
8
8
|
description = "Python Wrapper for Wikipedia"
|
|
9
9
|
readme = {file = "README_processed.rst", content-type = "text/x-rst"}
|
|
10
10
|
license = {text = "MIT"}
|
|
@@ -32,29 +32,28 @@ classifiers = [
|
|
|
32
32
|
]
|
|
33
33
|
requires-python = ">=3.10"
|
|
34
34
|
dependencies = [
|
|
35
|
-
"click==8.
|
|
35
|
+
"click==8.5.0",
|
|
36
36
|
"httpx==0.28.1",
|
|
37
37
|
"tenacity==9.1.4",
|
|
38
38
|
]
|
|
39
39
|
|
|
40
40
|
[dependency-groups]
|
|
41
41
|
dev = [
|
|
42
|
-
"coverage==7.
|
|
43
|
-
"ruff
|
|
42
|
+
"coverage==7.14.3",
|
|
43
|
+
"ruff==0.16.5",
|
|
44
44
|
"ty==0.0.27",
|
|
45
|
-
"pre-commit==4.
|
|
46
|
-
"pygments==2.
|
|
45
|
+
"pre-commit==4.6.0",
|
|
46
|
+
"pygments==2.21.0",
|
|
47
47
|
"pyupgrade==3.21.2",
|
|
48
|
-
"pytest==9.
|
|
49
|
-
"pytest-asyncio==1.
|
|
48
|
+
"pytest==9.1.1",
|
|
49
|
+
"pytest-asyncio==1.4.0",
|
|
50
50
|
"pytest-cov==7.1.0",
|
|
51
|
-
"tox==4.
|
|
52
|
-
"anyio[trio]==4.
|
|
51
|
+
"tox==4.56.1",
|
|
52
|
+
"anyio[trio]==4.14.2",
|
|
53
53
|
"respx==0.23.1",
|
|
54
|
-
"types-setuptools==82.0.0.
|
|
55
|
-
"pytest-recording
|
|
56
|
-
"vcrpy
|
|
57
|
-
"ty>=0.0.27",
|
|
54
|
+
"types-setuptools==82.0.0.20260518",
|
|
55
|
+
"pytest-recording==0.13.4",
|
|
56
|
+
"vcrpy==8.2.1",
|
|
58
57
|
]
|
|
59
58
|
doc = [
|
|
60
59
|
"sphinx==9.1.0; python_version >= '3.12'",
|
|
@@ -62,11 +61,11 @@ doc = [
|
|
|
62
61
|
build = [
|
|
63
62
|
"rst2html==2020.7.4",
|
|
64
63
|
"setuptools==82.0.1",
|
|
65
|
-
"twine
|
|
66
|
-
"wheel==0.
|
|
64
|
+
"twine==7.0.0",
|
|
65
|
+
"wheel==0.48.0",
|
|
67
66
|
]
|
|
68
67
|
testing = [
|
|
69
|
-
"anyio[trio]==4.
|
|
68
|
+
"anyio[trio]==4.14.2",
|
|
70
69
|
"respx==0.23.1",
|
|
71
70
|
]
|
|
72
71
|
|
{wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_http_client/async_http_client.py
RENAMED
|
@@ -48,10 +48,12 @@ class AsyncHTTPClient(BaseHTTPClient):
|
|
|
48
48
|
:class:`BaseHTTPClient`
|
|
49
49
|
"""
|
|
50
50
|
super().__init__(*args, **kwargs)
|
|
51
|
+
# Use a caller-supplied transport (e.g. a caching transport such as
|
|
52
|
+
# Hishel) if one was passed; otherwise fall back to the default.
|
|
53
|
+
self._client_kwargs.setdefault("transport", httpx.AsyncHTTPTransport())
|
|
51
54
|
self._client = httpx.AsyncClient(
|
|
52
55
|
headers=self._default_headers,
|
|
53
56
|
**self._client_kwargs,
|
|
54
|
-
transport=httpx.AsyncHTTPTransport(),
|
|
55
57
|
)
|
|
56
58
|
|
|
57
59
|
async def _do_get(self, url: str, params: dict[str, Any]) -> dict[str, Any]:
|
|
@@ -96,6 +96,10 @@ class BaseHTTPClient(ABC):
|
|
|
96
96
|
:param kwargs: forwarded to ``httpx`` client constructor
|
|
97
97
|
(e.g. ``timeout=30.0``, ``proxy={'https://': 'http://proxy.example.com:8080'}``,
|
|
98
98
|
``verify=False``, ``http2=True``); ``timeout`` defaults to ``10.0``.
|
|
99
|
+
A custom ``transport`` may also be supplied (e.g. a caching
|
|
100
|
+
transport such as `Hishel <https://hishel.com/httpx.html>`_); when
|
|
101
|
+
omitted, the default ``httpx.HTTPTransport`` /
|
|
102
|
+
``httpx.AsyncHTTPTransport`` is used.
|
|
99
103
|
**Advanced Usage**: These parameters provide direct access to httpx
|
|
100
104
|
capabilities. For standard Wikipedia API usage, prefer the
|
|
101
105
|
documented parameters above. Use httpx parameters only for
|
|
@@ -116,7 +120,7 @@ class BaseHTTPClient(ABC):
|
|
|
116
120
|
default_headers.get("User-Agent"),
|
|
117
121
|
)
|
|
118
122
|
|
|
119
|
-
default_headers["User-Agent"] = used_user_agent + "
|
|
123
|
+
default_headers["User-Agent"] = used_user_agent + " " + USER_AGENT
|
|
120
124
|
|
|
121
125
|
self.language = used_language
|
|
122
126
|
self.variant = used_variant
|
|
@@ -224,7 +228,8 @@ class BaseHTTPClient(ABC):
|
|
|
224
228
|
if not user_agent or len(user_agent) < MIN_USER_AGENT_LEN:
|
|
225
229
|
raise AssertionError(
|
|
226
230
|
"Please, be nice to Wikipedia and specify user agent - "
|
|
227
|
-
+ "https://
|
|
231
|
+
+ "https://foundation.wikimedia.org/wiki/Policy:Wikimedia_Foundation_"
|
|
232
|
+
+ "User-Agent_Policy. Current user_agent: '"
|
|
228
233
|
+ str(user_agent)
|
|
229
234
|
+ "' is not sufficient. "
|
|
230
235
|
+ "Use Wikipedia(user_agent='your-user-agent', language='"
|
|
@@ -46,10 +46,12 @@ class SyncHTTPClient(BaseHTTPClient):
|
|
|
46
46
|
:class:`BaseHTTPClient`
|
|
47
47
|
"""
|
|
48
48
|
super().__init__(*args, **kwargs)
|
|
49
|
+
# Use a caller-supplied transport (e.g. a caching transport such as
|
|
50
|
+
# Hishel) if one was passed; otherwise fall back to the default.
|
|
51
|
+
self._client_kwargs.setdefault("transport", httpx.HTTPTransport())
|
|
49
52
|
self._client = httpx.Client(
|
|
50
53
|
headers=self._default_headers,
|
|
51
54
|
**self._client_kwargs,
|
|
52
|
-
transport=httpx.HTTPTransport(),
|
|
53
55
|
)
|
|
54
56
|
|
|
55
57
|
def _do_get(self, url: str, params: dict[str, Any]) -> dict[str, Any]:
|
|
@@ -66,7 +66,8 @@ class AsyncWikipedia(AsyncWikipediaResource, AsyncHTTPClient):
|
|
|
66
66
|
``1.0``.
|
|
67
67
|
:param kwargs: additional keyword arguments forwarded to
|
|
68
68
|
``httpx.AsyncClient`` (e.g. ``timeout=30.0``, ``proxies={…}``,
|
|
69
|
-
``verify=False``
|
|
69
|
+
``verify=False``, or a custom ``transport`` such as a caching
|
|
70
|
+
transport). **Advanced Usage**: These provide direct
|
|
70
71
|
access to httpx capabilities. For most use cases, prefer the
|
|
71
72
|
standard parameters above. Use httpx parameters only for specific
|
|
72
73
|
requirements like custom proxies, SSL configuration, or connection pooling.
|
|
@@ -58,7 +58,8 @@ class Wikipedia(WikipediaResource, SyncHTTPClient):
|
|
|
58
58
|
``1.0``.
|
|
59
59
|
:param kwargs: additional keyword arguments forwarded to
|
|
60
60
|
``httpx.Client`` (e.g. ``timeout=30.0``, ``proxies={…}``,
|
|
61
|
-
``verify=False``
|
|
61
|
+
``verify=False``, or a custom ``transport`` such as a caching
|
|
62
|
+
transport). **Advanced Usage**: These provide direct
|
|
62
63
|
access to httpx capabilities. For most use cases, prefer the
|
|
63
64
|
standard parameters above. Use httpx parameters only for specific
|
|
64
65
|
requirements like custom proxies, SSL configuration, or connection pooling.
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
Development
|
|
2
|
-
===========
|
|
3
|
-
|
|
4
|
-
Prerequisites
|
|
5
|
-
--------------
|
|
6
|
-
|
|
7
|
-
* Make
|
|
8
|
-
* Python 3.10+
|
|
9
|
-
* Pip
|
|
10
|
-
|
|
11
|
-
Makefile targets
|
|
12
|
-
-----------------
|
|
13
|
-
* ``make run-type-check`` - type checks source code (runs ``uv run ty check wikipediaapi/``)
|
|
14
|
-
* ``make run-ruff`` - lints and checks formatting (runs ``ruff check`` and ``ruff format --check``)
|
|
15
|
-
* ``make requirements-all`` - install all requirements
|
|
16
|
-
* ``make requirements`` - install package requirements
|
|
17
|
-
* ``make requirements-dev`` - install development requirements
|
|
18
|
-
* ``make run-tests`` - run unit tests (pytest)
|
|
19
|
-
* ``make run-tests-integration`` - run VCR integration tests (pytest)
|
|
20
|
-
* ``make run-coverage`` - run code coverage (pytest-cov)
|
|
21
|
-
* ``make pypi-html`` - generates single HTML documentation into ``pypi-doc.html``
|
|
22
|
-
* ``make html`` - generates HTML documentation similar to RTFD into folder ``_build/html/``
|
|
23
|
-
* ``make release`` - creates new release as well as git tag
|
|
24
|
-
|
|
25
|
-
Usage Statistics
|
|
26
|
-
----------------
|
|
27
|
-
|
|
28
|
-
* `PIP Downloads`_
|
|
29
|
-
* `Clickpy`_
|
|
30
|
-
* `Libraries.io`_
|
|
31
|
-
* `Deps.dev`_
|
|
32
|
-
|
|
33
|
-
.. _PIP Downloads: https://pypistats.org/packages/wikipedia-api
|
|
34
|
-
.. _Libraries.io: https://libraries.io/pypi/Wikipedia-API
|
|
35
|
-
.. _Deps.dev: https://deps.dev/pypi/wikipedia-api
|
|
36
|
-
.. _Clickpy: https://clickpy.clickhouse.com/dashboard/wikipedia-api
|
|
37
|
-
|
|
38
|
-
Underlying API
|
|
39
|
-
--------------
|
|
40
|
-
|
|
41
|
-
* `API - HP`_
|
|
42
|
-
* `Module - Parse`_
|
|
43
|
-
* `Module - Query`_
|
|
44
|
-
|
|
45
|
-
.. _API - HP: https://www.mediawiki.org/wiki/API:Main_page
|
|
46
|
-
.. _Module - Parse: https://en.wikipedia.org/w/api.php?action=help&modules=parse
|
|
47
|
-
.. _Module - Query: https://en.wikipedia.org/w/api.php?action=help&modules=query
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_resources/async_wikipedia_resource.py
RENAMED
|
File without changes
|
{wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/_resources/base_wikipedia_resource.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/exceptions/wiki_connection_error.py
RENAMED
|
File without changes
|
|
File without changes
|
{wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/exceptions/wiki_http_timeout_error.py
RENAMED
|
File without changes
|
{wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/exceptions/wiki_invalid_json_error.py
RENAMED
|
File without changes
|
{wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/exceptions/wiki_rate_limit_error.py
RENAMED
|
File without changes
|
{wikipedia_api-0.14.1 → wikipedia_api-0.16.0}/wikipediaapi/exceptions/wikipedia_exception.py
RENAMED
|
File without changes
|
|
File without changes
|