A thin MediaWiki client using requests.
Project description
Yet another MediaWiki client library for Python. It’s not stable yet and it requires Python 3.9+!
Installation
pip install pymw
Usage
To avoid directly providing username and password for login calls create a .pymw.json file in your home directory with the following format:
{
"https://test.wikipedia.org/w/api.php": {
"<Username@Special:BotPasswords>": {
"BotPassword": "<BotPassword>"
},
"<Username2>": {
"BotPassword": "<BotPassword>",
"limit": 500
}
},
"https://*.wikipedia.org/w/api.php": {
"<Username>": {
"BotPassword": "<BotPassword>"
}
}
}
As you can see, glob patterns are supported.
Notable features
Has a post_and_continue method that can handle continuations.
Parameter values can be str or any Python iterable. Iterable values that are not an str instance will be converted to a pipe-joined str before being sent.
The post_and_continue method automatically breaks a value that has too many items in it into several API calls according the API limit for the current user and yields the results. (Currently this feature works only if there is just one violating parameter. The algorithm might be improved in the future to handle more complex situations.)
prop method handles batchcomplete signals for prop queries and yields the results as soon as a batch is complete.
Configurable maxlag. Waits as the API recommends and then retries.
Automatically tries to login before performing actions that are known to require login.
Automatically tries to login if an API call returns login-required error (requires username and password to be set in ~/.pymw.json).
Some convenient methods for accessing common API calls, e.g. for login and upload.
Lightweight. pymw is a thin wrapper. Method signatures are very similar to the parameters in an actual API URL. You can consult MediaWiki’s documentation if in doubt about what a parameter does.
The post_and_continue method can handle most toomanyvalues errors by automatically splitting the violating parameter into several API calls. (not a feature to rely on in production, but nice to have during a console session for example.)
Supports setting a custom User-Agent header for each API instance.
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
File details
Details for the file pymw-0.9.1.tar.gz
.
File metadata
- Download URL: pymw-0.9.1.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.9.0b5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14a30db808d4f7b907adb11546c17a3f3e328254c823d01c2e105dbb02e4da51 |
|
MD5 | c65de1d3af2dac309a7a5e2c82e27449 |
|
BLAKE2b-256 | 48862c18f7386dd73a67dcf5aca7370d00dd6bf2554f63b659e9a78dd4486cee |
File details
Details for the file pymw-0.9.1-py3-none-any.whl
.
File metadata
- Download URL: pymw-0.9.1-py3-none-any.whl
- Upload date:
- Size: 22.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.9.0b5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cd083cd24af86f83475341b3081dfa6f8619724b253c2e636f1369dc63b2270 |
|
MD5 | 596fb4f13a8a8ce1727478cb67793058 |
|
BLAKE2b-256 | 1a98a57ce303ce57cc871f9798a583ed4c86552cad14015258c6eeb87faf7b68 |