[Python-modules-commits] [mwclient] 01/04: New upstream version 0.8.6
Hans-Christoph Steiner
eighthave at moszumanska.debian.org
Wed Jan 10 11:26:57 UTC 2018
This is an automated email from the git hooks/post-receive script.
eighthave pushed a commit to branch master
in repository mwclient.
commit 0e485efb41e84039d9ba4a0ef41ac540691dd116
Author: Hans-Christoph Steiner <hans at eds.org>
Date: Wed Jan 10 11:17:57 2018 +0100
New upstream version 0.8.6
---
LICENSE.md | 22 +
MANIFEST.in | 1 +
PKG-INFO | 159 +++++
README.rst | 142 +++++
mwclient.egg-info/PKG-INFO | 159 +++++
mwclient.egg-info/SOURCES.txt | 21 +
mwclient.egg-info/dependency_links.txt | 1 +
mwclient.egg-info/pbr.json | 1 +
mwclient.egg-info/requires.txt | 2 +
mwclient.egg-info/top_level.txt | 1 +
mwclient.egg-info/zip-safe | 1 +
mwclient/__init__.py | 42 ++
mwclient/client.py | 1010 ++++++++++++++++++++++++++++++++
mwclient/errors.py | 104 ++++
mwclient/ex.py | 87 +++
mwclient/image.py | 66 +++
mwclient/listing.py | 311 ++++++++++
mwclient/page.py | 475 +++++++++++++++
mwclient/sleep.py | 49 ++
mwclient/util.py | 7 +
setup.cfg | 25 +
setup.py | 34 ++
22 files changed, 2720 insertions(+)
diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 0000000..9359f20
--- /dev/null
+++ b/LICENSE.md
@@ -0,0 +1,22 @@
+Copyright (c) 2006-2013 Bryan Tong Minh
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..e267daf
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1 @@
+include LICENSE.md
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..d025f61
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,159 @@
+Metadata-Version: 1.1
+Name: mwclient
+Version: 0.8.6
+Summary: MediaWiki API client
+Home-page: https://github.com/btongminh/mwclient
+Author: Bryan Tong Minh
+Author-email: bryan.tongminh at gmail.com
+License: MIT
+Description:
+ .. figure:: docs/source/logo.png
+ :alt: Logo
+ :align: center
+
+ mwclient
+ ========
+
+ .. image:: https://img.shields.io/travis/mwclient/mwclient.svg
+ :target: https://travis-ci.org/mwclient/mwclient
+ :alt: Build status
+
+ .. image:: https://img.shields.io/coveralls/mwclient/mwclient.svg
+ :target: https://coveralls.io/r/mwclient/mwclient
+ :alt: Test coverage
+
+ .. image:: https://landscape.io/github/mwclient/mwclient/master/landscape.svg?style=flat
+ :target: https://landscape.io/github/mwclient/mwclient/master
+ :alt: Code health
+
+ .. image:: https://img.shields.io/pypi/v/mwclient.svg
+ :target: https://pypi.python.org/pypi/mwclient
+ :alt: Latest version
+
+ .. image:: https://img.shields.io/pypi/dw/mwclient.svg
+ :target: https://pypi.python.org/pypi/mwclient
+ :alt: Downloads
+
+ .. image:: https://img.shields.io/github/license/mwclient/mwclient.svg
+ :target: http://opensource.org/licenses/MIT
+ :alt: MIT license
+
+ .. image:: https://readthedocs.org/projects/mwclient/badge/?version=master
+ :target: http://mwclient.readthedocs.io/en/latest/
+ :alt: Documentation status
+
+ .. image:: http://isitmaintained.com/badge/resolution/tldr-pages/tldr.svg
+ :target: http://isitmaintained.com/project/tldr-pages/tldr
+ :alt: Issue statistics
+
+ mwclient is a lightweight Python client library to the `MediaWiki API <https://mediawiki.org/wiki/API>`_
+ which provides access to most API functionality.
+ It works with Python 2.7, 3.3 and above, and supports MediaWiki 1.16 and above.
+ For functions not available in the current MediaWiki, a ``MediaWikiVersionError`` is raised.
+
+ The current stable `version 0.8.6 <https://github.com/mwclient/mwclient/archive/v0.8.6.zip>`_
+ was released on 18 May 2017, and is `available through PyPI <https://pypi.python.org/pypi/mwclient>`_:
+
+ .. code-block:: console
+
+ $ pip install mwclient
+
+ The current `development version <https://github.com/mwclient/mwclient>`_
+ can be installed from GitHub:
+
+ .. code-block:: console
+
+ $ pip install git+git://github.com/mwclient/mwclient.git
+
+ Please see the
+ `changelog document <https://github.com/mwclient/mwclient/blob/master/CHANGELOG.md>`_
+ for a list of changes.
+
+ Getting started
+ ---------------
+
+ See the `user guide <http://mwclient.readthedocs.io/en/latest/user/index.html>`_
+ to get started using mwclient.
+
+ For more information, see the
+ `REFERENCE.md <https://github.com/mwclient/mwclient/blob/master/REFERENCE.md>`_ file
+ and the `documentation on the wiki <https://github.com/mwclient/mwclient/wiki>`_.
+
+
+ Contributing
+ --------------------
+
+ mwclient ships with a test suite based on `pytest <https://pytest.org>`_.
+ Only a small part of mwclient is currently tested,
+ but hopefully coverage will improve in the future.
+
+ The easiest way to run tests is:
+
+ .. code-block:: console
+
+ $ python setup.py test
+
+ This will make an in-place build and download test dependencies locally
+ if needed. To make tests run faster, you can use pip to do an
+ `"editable" install <https://pip.readthedocs.org/en/latest/reference/pip_install.html#editable-installs>`_:
+
+ .. code-block:: console
+
+ $ pip install pytest pytest-pep8 responses
+ $ pip install -e .
+ $ py.test
+
+ To run tests with different Python versions in isolated virtualenvs, you
+ can use `Tox <https://testrun.org/tox/latest/>`_:
+
+ .. code-block:: console
+
+ $ pip install tox
+ $ tox
+
+ *Documentation* consists of both a manually compiled user guide (under ``docs/user``)
+ and a reference guide generated from the docstrings,
+ using Sphinx autodoc with the napoleon extension.
+ Documentation is built automatically on `ReadTheDocs`_ after each commit.
+ To build documentation locally for testing, do:
+
+ .. code-block:: console
+
+ $ cd docs
+ $ make html
+
+ When writing docstrings, try to adhere to the `Google style`_.
+
+ .. _Google style: https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html
+ .. _ReadTheDocs: https://mwclient.readthedocs.io/
+
+ Implementation notes
+ --------------------
+
+ Most properties and generators accept the same parameters as the API,
+ without their two-letter prefix. Exceptions to this rule:
+
+ * ``Image.imageinfo`` is the imageinfo of the latest image.
+ Earlier versions can be fetched using ``imagehistory()``
+ * ``Site.all*``: parameter ``[ap]from`` renamed to ``start``
+ * ``categorymembers`` is implemented as ``Category.members``
+ * ``deletedrevs`` is ``deletedrevisions``
+ * ``usercontribs`` is ``usercontributions``
+ * First parameters of ``search`` and ``usercontributions`` are ``search`` and ``user``
+ respectively
+
+ Properties and generators are implemented as Python generators.
+ Their limit parameter is only an indication of the number of items in one chunk.
+ It is not the total limit.
+ Doing ``list(generator(limit = limit))`` will return ALL items of generator,
+ and not be limited by the limit value.
+ Default chunk size is generally the maximum chunk size.
+
+Keywords: mediawiki wikipedia
+Platform: UNKNOWN
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..7baaffa
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,142 @@
+
+.. figure:: docs/source/logo.png
+ :alt: Logo
+ :align: center
+
+mwclient
+========
+
+.. image:: https://img.shields.io/travis/mwclient/mwclient.svg
+ :target: https://travis-ci.org/mwclient/mwclient
+ :alt: Build status
+
+.. image:: https://img.shields.io/coveralls/mwclient/mwclient.svg
+ :target: https://coveralls.io/r/mwclient/mwclient
+ :alt: Test coverage
+
+.. image:: https://landscape.io/github/mwclient/mwclient/master/landscape.svg?style=flat
+ :target: https://landscape.io/github/mwclient/mwclient/master
+ :alt: Code health
+
+.. image:: https://img.shields.io/pypi/v/mwclient.svg
+ :target: https://pypi.python.org/pypi/mwclient
+ :alt: Latest version
+
+.. image:: https://img.shields.io/pypi/dw/mwclient.svg
+ :target: https://pypi.python.org/pypi/mwclient
+ :alt: Downloads
+
+.. image:: https://img.shields.io/github/license/mwclient/mwclient.svg
+ :target: http://opensource.org/licenses/MIT
+ :alt: MIT license
+
+.. image:: https://readthedocs.org/projects/mwclient/badge/?version=master
+ :target: http://mwclient.readthedocs.io/en/latest/
+ :alt: Documentation status
+
+.. image:: http://isitmaintained.com/badge/resolution/tldr-pages/tldr.svg
+ :target: http://isitmaintained.com/project/tldr-pages/tldr
+ :alt: Issue statistics
+
+mwclient is a lightweight Python client library to the `MediaWiki API <https://mediawiki.org/wiki/API>`_
+which provides access to most API functionality.
+It works with Python 2.7, 3.3 and above, and supports MediaWiki 1.16 and above.
+For functions not available in the current MediaWiki, a ``MediaWikiVersionError`` is raised.
+
+The current stable `version 0.8.6 <https://github.com/mwclient/mwclient/archive/v0.8.6.zip>`_
+was released on 18 May 2017, and is `available through PyPI <https://pypi.python.org/pypi/mwclient>`_:
+
+.. code-block:: console
+
+ $ pip install mwclient
+
+The current `development version <https://github.com/mwclient/mwclient>`_
+can be installed from GitHub:
+
+.. code-block:: console
+
+ $ pip install git+git://github.com/mwclient/mwclient.git
+
+Please see the
+`changelog document <https://github.com/mwclient/mwclient/blob/master/CHANGELOG.md>`_
+for a list of changes.
+
+Getting started
+---------------
+
+See the `user guide <http://mwclient.readthedocs.io/en/latest/user/index.html>`_
+to get started using mwclient.
+
+For more information, see the
+`REFERENCE.md <https://github.com/mwclient/mwclient/blob/master/REFERENCE.md>`_ file
+and the `documentation on the wiki <https://github.com/mwclient/mwclient/wiki>`_.
+
+
+Contributing
+--------------------
+
+mwclient ships with a test suite based on `pytest <https://pytest.org>`_.
+Only a small part of mwclient is currently tested,
+but hopefully coverage will improve in the future.
+
+The easiest way to run tests is:
+
+.. code-block:: console
+
+ $ python setup.py test
+
+This will make an in-place build and download test dependencies locally
+if needed. To make tests run faster, you can use pip to do an
+`"editable" install <https://pip.readthedocs.org/en/latest/reference/pip_install.html#editable-installs>`_:
+
+.. code-block:: console
+
+ $ pip install pytest pytest-pep8 responses
+ $ pip install -e .
+ $ py.test
+
+To run tests with different Python versions in isolated virtualenvs, you
+can use `Tox <https://testrun.org/tox/latest/>`_:
+
+.. code-block:: console
+
+ $ pip install tox
+ $ tox
+
+*Documentation* consists of both a manually compiled user guide (under ``docs/user``)
+and a reference guide generated from the docstrings,
+using Sphinx autodoc with the napoleon extension.
+Documentation is built automatically on `ReadTheDocs`_ after each commit.
+To build documentation locally for testing, do:
+
+.. code-block:: console
+
+ $ cd docs
+ $ make html
+
+When writing docstrings, try to adhere to the `Google style`_.
+
+.. _Google style: https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html
+.. _ReadTheDocs: https://mwclient.readthedocs.io/
+
+Implementation notes
+--------------------
+
+Most properties and generators accept the same parameters as the API,
+without their two-letter prefix. Exceptions to this rule:
+
+* ``Image.imageinfo`` is the imageinfo of the latest image.
+ Earlier versions can be fetched using ``imagehistory()``
+* ``Site.all*``: parameter ``[ap]from`` renamed to ``start``
+* ``categorymembers`` is implemented as ``Category.members``
+* ``deletedrevs`` is ``deletedrevisions``
+* ``usercontribs`` is ``usercontributions``
+* First parameters of ``search`` and ``usercontributions`` are ``search`` and ``user``
+ respectively
+
+Properties and generators are implemented as Python generators.
+Their limit parameter is only an indication of the number of items in one chunk.
+It is not the total limit.
+Doing ``list(generator(limit = limit))`` will return ALL items of generator,
+and not be limited by the limit value.
+Default chunk size is generally the maximum chunk size.
diff --git a/mwclient.egg-info/PKG-INFO b/mwclient.egg-info/PKG-INFO
new file mode 100644
index 0000000..d025f61
--- /dev/null
+++ b/mwclient.egg-info/PKG-INFO
@@ -0,0 +1,159 @@
+Metadata-Version: 1.1
+Name: mwclient
+Version: 0.8.6
+Summary: MediaWiki API client
+Home-page: https://github.com/btongminh/mwclient
+Author: Bryan Tong Minh
+Author-email: bryan.tongminh at gmail.com
+License: MIT
+Description:
+ .. figure:: docs/source/logo.png
+ :alt: Logo
+ :align: center
+
+ mwclient
+ ========
+
+ .. image:: https://img.shields.io/travis/mwclient/mwclient.svg
+ :target: https://travis-ci.org/mwclient/mwclient
+ :alt: Build status
+
+ .. image:: https://img.shields.io/coveralls/mwclient/mwclient.svg
+ :target: https://coveralls.io/r/mwclient/mwclient
+ :alt: Test coverage
+
+ .. image:: https://landscape.io/github/mwclient/mwclient/master/landscape.svg?style=flat
+ :target: https://landscape.io/github/mwclient/mwclient/master
+ :alt: Code health
+
+ .. image:: https://img.shields.io/pypi/v/mwclient.svg
+ :target: https://pypi.python.org/pypi/mwclient
+ :alt: Latest version
+
+ .. image:: https://img.shields.io/pypi/dw/mwclient.svg
+ :target: https://pypi.python.org/pypi/mwclient
+ :alt: Downloads
+
+ .. image:: https://img.shields.io/github/license/mwclient/mwclient.svg
+ :target: http://opensource.org/licenses/MIT
+ :alt: MIT license
+
+ .. image:: https://readthedocs.org/projects/mwclient/badge/?version=master
+ :target: http://mwclient.readthedocs.io/en/latest/
+ :alt: Documentation status
+
+ .. image:: http://isitmaintained.com/badge/resolution/tldr-pages/tldr.svg
+ :target: http://isitmaintained.com/project/tldr-pages/tldr
+ :alt: Issue statistics
+
+ mwclient is a lightweight Python client library to the `MediaWiki API <https://mediawiki.org/wiki/API>`_
+ which provides access to most API functionality.
+ It works with Python 2.7, 3.3 and above, and supports MediaWiki 1.16 and above.
+ For functions not available in the current MediaWiki, a ``MediaWikiVersionError`` is raised.
+
+ The current stable `version 0.8.6 <https://github.com/mwclient/mwclient/archive/v0.8.6.zip>`_
+ was released on 18 May 2017, and is `available through PyPI <https://pypi.python.org/pypi/mwclient>`_:
+
+ .. code-block:: console
+
+ $ pip install mwclient
+
+ The current `development version <https://github.com/mwclient/mwclient>`_
+ can be installed from GitHub:
+
+ .. code-block:: console
+
+ $ pip install git+git://github.com/mwclient/mwclient.git
+
+ Please see the
+ `changelog document <https://github.com/mwclient/mwclient/blob/master/CHANGELOG.md>`_
+ for a list of changes.
+
+ Getting started
+ ---------------
+
+ See the `user guide <http://mwclient.readthedocs.io/en/latest/user/index.html>`_
+ to get started using mwclient.
+
+ For more information, see the
+ `REFERENCE.md <https://github.com/mwclient/mwclient/blob/master/REFERENCE.md>`_ file
+ and the `documentation on the wiki <https://github.com/mwclient/mwclient/wiki>`_.
+
+
+ Contributing
+ --------------------
+
+ mwclient ships with a test suite based on `pytest <https://pytest.org>`_.
+ Only a small part of mwclient is currently tested,
+ but hopefully coverage will improve in the future.
+
+ The easiest way to run tests is:
+
+ .. code-block:: console
+
+ $ python setup.py test
+
+ This will make an in-place build and download test dependencies locally
+ if needed. To make tests run faster, you can use pip to do an
+ `"editable" install <https://pip.readthedocs.org/en/latest/reference/pip_install.html#editable-installs>`_:
+
+ .. code-block:: console
+
+ $ pip install pytest pytest-pep8 responses
+ $ pip install -e .
+ $ py.test
+
+ To run tests with different Python versions in isolated virtualenvs, you
+ can use `Tox <https://testrun.org/tox/latest/>`_:
+
+ .. code-block:: console
+
+ $ pip install tox
+ $ tox
+
+ *Documentation* consists of both a manually compiled user guide (under ``docs/user``)
+ and a reference guide generated from the docstrings,
+ using Sphinx autodoc with the napoleon extension.
+ Documentation is built automatically on `ReadTheDocs`_ after each commit.
+ To build documentation locally for testing, do:
+
+ .. code-block:: console
+
+ $ cd docs
+ $ make html
+
+ When writing docstrings, try to adhere to the `Google style`_.
+
+ .. _Google style: https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html
+ .. _ReadTheDocs: https://mwclient.readthedocs.io/
+
+ Implementation notes
+ --------------------
+
+ Most properties and generators accept the same parameters as the API,
+ without their two-letter prefix. Exceptions to this rule:
+
+ * ``Image.imageinfo`` is the imageinfo of the latest image.
+ Earlier versions can be fetched using ``imagehistory()``
+ * ``Site.all*``: parameter ``[ap]from`` renamed to ``start``
+ * ``categorymembers`` is implemented as ``Category.members``
+ * ``deletedrevs`` is ``deletedrevisions``
+ * ``usercontribs`` is ``usercontributions``
+ * First parameters of ``search`` and ``usercontributions`` are ``search`` and ``user``
+ respectively
+
+ Properties and generators are implemented as Python generators.
+ Their limit parameter is only an indication of the number of items in one chunk.
+ It is not the total limit.
+ Doing ``list(generator(limit = limit))`` will return ALL items of generator,
+ and not be limited by the limit value.
+ Default chunk size is generally the maximum chunk size.
+
+Keywords: mediawiki wikipedia
+Platform: UNKNOWN
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
diff --git a/mwclient.egg-info/SOURCES.txt b/mwclient.egg-info/SOURCES.txt
new file mode 100644
index 0000000..f2fd21b
--- /dev/null
+++ b/mwclient.egg-info/SOURCES.txt
@@ -0,0 +1,21 @@
+LICENSE.md
+MANIFEST.in
+README.rst
+setup.cfg
+setup.py
+mwclient/__init__.py
+mwclient/client.py
+mwclient/errors.py
+mwclient/ex.py
+mwclient/image.py
+mwclient/listing.py
+mwclient/page.py
+mwclient/sleep.py
+mwclient/util.py
+mwclient.egg-info/PKG-INFO
+mwclient.egg-info/SOURCES.txt
+mwclient.egg-info/dependency_links.txt
+mwclient.egg-info/pbr.json
+mwclient.egg-info/requires.txt
+mwclient.egg-info/top_level.txt
+mwclient.egg-info/zip-safe
\ No newline at end of file
diff --git a/mwclient.egg-info/dependency_links.txt b/mwclient.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/mwclient.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/mwclient.egg-info/pbr.json b/mwclient.egg-info/pbr.json
new file mode 100644
index 0000000..0541deb
--- /dev/null
+++ b/mwclient.egg-info/pbr.json
@@ -0,0 +1 @@
+{"is_release": false, "git_version": "c23abae"}
\ No newline at end of file
diff --git a/mwclient.egg-info/requires.txt b/mwclient.egg-info/requires.txt
new file mode 100644
index 0000000..21258bd
--- /dev/null
+++ b/mwclient.egg-info/requires.txt
@@ -0,0 +1,2 @@
+requests_oauthlib
+six
diff --git a/mwclient.egg-info/top_level.txt b/mwclient.egg-info/top_level.txt
new file mode 100644
index 0000000..fb1111e
--- /dev/null
+++ b/mwclient.egg-info/top_level.txt
@@ -0,0 +1 @@
+mwclient
diff --git a/mwclient.egg-info/zip-safe b/mwclient.egg-info/zip-safe
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/mwclient.egg-info/zip-safe
@@ -0,0 +1 @@
+
diff --git a/mwclient/__init__.py b/mwclient/__init__.py
new file mode 100644
index 0000000..665c3dc
--- /dev/null
+++ b/mwclient/__init__.py
@@ -0,0 +1,42 @@
+"""
+ Copyright (c) 2006-2011 Bryan Tong Minh
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+"""
+
+from mwclient.errors import * # pylint: disable=unused-import
+from mwclient.client import Site, __ver__ # pylint: disable=unused-import
+import logging
+import warnings
+
+# Show DeprecationWarning
+warnings.simplefilter('always', DeprecationWarning)
+
+# Logging: Add a null handler to avoid "No handler found" warnings.
+try:
+ from logging import NullHandler
+except ImportError:
+ class NullHandler(logging.Handler):
+ def emit(self, record):
+ pass
+
+logging.getLogger(__name__).addHandler(NullHandler())
diff --git a/mwclient/client.py b/mwclient/client.py
new file mode 100644
index 0000000..a954fdf
--- /dev/null
+++ b/mwclient/client.py
@@ -0,0 +1,1010 @@
+# encoding=utf-8
+import warnings
+import logging
+from six import text_type
+import six
+
+from collections import OrderedDict
+
+try:
+ import json
+except ImportError:
+ import simplejson as json
+import requests
+from requests.auth import HTTPBasicAuth, AuthBase
+from requests_oauthlib import OAuth1
+
+import mwclient.errors as errors
+import mwclient.listing as listing
+from mwclient.sleep import Sleepers
+from mwclient.util import parse_timestamp
+
+try:
+ import gzip
+except ImportError:
+ gzip = None
+
+__ver__ = '0.8.6'
+
+log = logging.getLogger(__name__)
+
+
+class Site(object):
+ """A MediaWiki site identified by its hostname.
+
+ >>> import mwclient
+ >>> site = mwclient.Site('en.wikipedia.org')
+
+ Do not include the leading "http://".
+
+ Mwclient assumes that the script path (where index.php and api.php are located)
+ is '/w/'. If the site uses a different script path, you must specify this
+ (path must end in a '/').
+
+ Examples:
+
+ >>> site = mwclient.Site('vim.wikia.com', path='/')
+ >>> site = mwclient.Site('sourceforge.net', path='/apps/mediawiki/mwclient/')
+
+ """
+ api_limit = 500
+
+ def __init__(self, host, path='/w/', ext='.php', pool=None, retry_timeout=30,
+ max_retries=25, wait_callback=lambda *x: None, clients_useragent=None,
+ max_lag=3, compress=True, force_login=True, do_init=True, httpauth=None,
+ reqs=None, consumer_token=None, consumer_secret=None, access_token=None,
+ access_secret=None, client_certificate=None, custom_headers=None):
+ # Setup member variables
+ self.host = host
+ self.path = path
+ self.ext = ext
+ self.credentials = None
+ self.compress = compress
+ self.max_lag = text_type(max_lag)
+ self.force_login = force_login
+ self.requests = reqs or {}
+
+ if consumer_token is not None:
+ auth = OAuth1(consumer_token, consumer_secret, access_token, access_secret)
+ elif isinstance(httpauth, (list, tuple)):
+ auth = HTTPBasicAuth(*httpauth)
+ elif httpauth is None or isinstance(httpauth, (AuthBase,)):
+ auth = httpauth
+ else:
+ raise RuntimeError('Authentication is not a tuple or an instance of AuthBase')
+
+ self.sleepers = Sleepers(max_retries, retry_timeout, wait_callback)
+
+ # Site properties
+ self.blocked = False # Whether current user is blocked
+ self.hasmsg = False # Whether current user has new messages
+ self.groups = [] # Groups current user belongs to
+ self.rights = [] # Rights current user has
+ self.tokens = {} # Edit tokens of the current user
+ self.version = None
+
+ self.namespaces = self.default_namespaces
+ self.writeapi = False
+
+ # Setup connection
+ if pool is None:
+ self.connection = requests.Session()
+ self.connection.auth = auth
+ if client_certificate:
+ self.connection.cert = client_certificate
+
+ prefix = '{} - '.format(clients_useragent) if clients_useragent else ''
+ self.connection.headers['User-Agent'] = (
+ '{prefix}MwClient/{ver} ({url})'.format(
+ prefix=prefix,
+ ver=__ver__,
+ url='https://github.com/mwclient/mwclient'
+ )
+ )
+ if custom_headers:
+ self.connection.headers.update(custom_headers)
+ else:
+ self.connection = pool
+
+ # Page generators
+ self.pages = listing.PageList(self)
+ self.categories = listing.PageList(self, namespace=14)
+ self.images = listing.PageList(self, namespace=6)
+
+ # Compat page generators
+ self.Pages = self.pages
+ self.Categories = self.categories
+ self.Images = self.images
+
+ # Initialization status
+ self.initialized = False
+
+ if do_init:
+ try:
+ self.site_init()
+ except errors.APIError as e:
+ if e.args[0] == 'mwoauth-invalid-authorization':
+ raise errors.OAuthAuthorizationError(e.code, e.info)
+
+ # Private wiki, do init after login
+ if e.args[0] not in {u'unknown_action', u'readapidenied'}:
+ raise
+
+ def site_init(self):
+
+ if self.initialized:
+ info = self.get('query', meta='userinfo', uiprop='groups|rights')
+ userinfo = info['query']['userinfo']
+ self.username = userinfo['name']
+ self.groups = userinfo.get('groups', [])
+ self.rights = userinfo.get('rights', [])
+ self.tokens = {}
+ return
+
+ meta = self.get('query', meta='siteinfo|userinfo',
+ siprop='general|namespaces', uiprop='groups|rights',
+ retry_on_error=False)
+
+ # Extract site info
+ self.site = meta['query']['general']
+ self.namespaces = {
+ namespace['id']: namespace.get('*', '')
+ for namespace in six.itervalues(meta['query']['namespaces'])
+ }
+ self.writeapi = 'writeapi' in self.site
+
+ self.version = self.version_tuple_from_generator(self.site['generator'])
+
+ # Require MediaWiki version >= 1.16
+ self.require(1, 16)
+
+ # User info
+ userinfo = meta['query']['userinfo']
+ self.username = userinfo['name']
+ self.groups = userinfo.get('groups', [])
+ self.rights = userinfo.get('rights', [])
+ self.initialized = True
+
+ @staticmethod
+ def version_tuple_from_generator(string, prefix='MediaWiki '):
+ """Return a version tuple from a MediaWiki Generator string.
+
+ Example:
+ "MediaWiki 1.5.1" → (1, 5, 1)
+
+ Args:
+ prefix (str): The expected prefix of the string
+ """
+ if not string.startswith(prefix):
+ raise errors.MediaWikiVersionError('Unknown generator {}'.format(string))
+
+ version = string[len(prefix):].split('.')
+
+ def split_num(s):
+ """Split the string on the first non-digit character.
+
+ Returns:
+ A tuple of the digit part as int and, if available,
+ the rest of the string.
+ """
+ i = 0
+ while i < len(s):
+ if s[i] < '0' or s[i] > '9':
+ break
+ i += 1
+ if s[i:]:
+ return (int(s[:i]), s[i:], )
+ else:
+ return (int(s[:i]), )
+
+ version_tuple = sum((split_num(s) for s in version), ())
+
+ if len(version_tuple) < 2:
+ raise errors.MediaWikiVersionError('Unknown MediaWiki {}'
+ .format('.'.join(version)))
+
+ return version_tuple
+
+ default_namespaces = {
+ 0: u'', 1: u'Talk', 2: u'User', 3: u'User talk', 4: u'Project',
+ 5: u'Project talk', 6: u'Image', 7: u'Image talk', 8: u'MediaWiki',
+ 9: u'MediaWiki talk', 10: u'Template', 11: u'Template talk', 12: u'Help',
+ 13: u'Help talk', 14: u'Category', 15: u'Category talk',
+ -1: u'Special', -2: u'Media'
+ }
+
+ def __repr__(self):
+ return "<Site object '%s%s'>" % (self.host, self.path)
+
+ def get(self, action, *args, **kwargs):
+ """Perform a generic API call using GET.
+
+ This is just a shorthand for calling api() with http_method='GET'.
+ All arguments will be passed on.
+
+ Returns:
+ The raw response from the API call, as a dictionary.
+ """
+ return self.api(action, 'GET', *args, **kwargs)
+
+ def post(self, action, *args, **kwargs):
+ """Perform a generic API call using POST.
+
+ This is just a shorthand for calling api() with http_method='POST'.
+ All arguments will be passed on.
+
+ Returns:
+ The raw response from the API call, as a dictionary.
+ """
+ return self.api(action, 'POST', *args, **kwargs)
+
+ def api(self, action, http_method='POST', *args, **kwargs):
+ """Perform a generic API call and handle errors.
+
+ All arguments will be passed on.
+
+ Example:
+ To get coordinates from the GeoData MediaWiki extension at English Wikipedia:
+
+ >>> site = Site('en.wikipedia.org')
+ >>> result = site.api('query', prop='coordinates', titles='Oslo|Copenhagen')
+ >>> for page in result['query']['pages'].values():
+ ... if 'coordinates' in page:
+ ... print '{} {} {}'.format(page['title'],
+ ... page['coordinates'][0]['lat'],
+ ... page['coordinates'][0]['lon'])
+ Oslo 59.95 10.75
+ Copenhagen 55.6761 12.5683
+
+ Returns:
+ The raw response from the API call, as a dictionary.
+ """
+ kwargs.update(args)
+
+ if action == 'query' and 'continue' not in kwargs:
+ kwargs['continue'] = ''
+ if action == 'query':
+ if 'meta' in kwargs:
+ kwargs['meta'] += '|userinfo'
+ else:
+ kwargs['meta'] = 'userinfo'
+ if 'uiprop' in kwargs:
+ kwargs['uiprop'] += '|blockinfo|hasmsg'
+ else:
+ kwargs['uiprop'] = 'blockinfo|hasmsg'
+
+ sleeper = self.sleepers.make()
+
+ while True:
+ info = self.raw_api(action, http_method, **kwargs)
+ if not info:
+ info = {}
+ if self.handle_api_result(info, sleeper=sleeper):
+ return info
+
+ def handle_api_result(self, info, kwargs=None, sleeper=None):
+ if sleeper is None:
+ sleeper = self.sleepers.make()
+
+ try:
+ userinfo = info['query']['userinfo']
+ except KeyError:
+ userinfo = ()
+ if 'blockedby' in userinfo:
+ self.blocked = (userinfo['blockedby'], userinfo.get('blockreason', u''))
+ else:
+ self.blocked = False
+ self.hasmsg = 'messages' in userinfo
+ self.logged_in = 'anon' not in userinfo
+ if 'warnings' in info:
+ for module, warning in info['warnings'].items():
+ if '*' in warning:
+ log.warning(warning['*'])
+
+ if 'error' in info:
+ if info['error'].get('code') in {u'internal_api_error_DBConnectionError',
+ u'internal_api_error_DBQueryError'}:
+ sleeper.sleep()
+ return False
+
+ # cope with https://phabricator.wikimedia.org/T106066
+ if (info['error'].get('code') == u'mwoauth-invalid-authorization' and
+ 'Nonce already used' in info['error'].get('info')):
+ log.warning('retrying due to nonce error https://phabricator.wikimedia.org/T106066')
+ sleeper.sleep()
+ return False
+
+ if 'query' in info['error']:
+ # Semantic Mediawiki does not follow the standard error format
+ raise errors.APIError(None, info['error']['query'], kwargs)
+
+ if '*' in info['error']:
+ raise errors.APIError(info['error']['code'],
+ info['error']['info'], info['error']['*'])
+ raise errors.APIError(info['error']['code'],
+ info['error']['info'], kwargs)
+ return True
+
+ @staticmethod
+ def _query_string(*args, **kwargs):
+ kwargs.update(args)
+ qs1 = [(k, v) for k, v in six.iteritems(kwargs) if k not in {'wpEditToken', 'token'}]
+ qs2 = [(k, v) for k, v in six.iteritems(kwargs) if k in {'wpEditToken', 'token'}]
+ return OrderedDict(qs1 + qs2)
+
+ def raw_call(self, script, data, files=None, retry_on_error=True, http_method='POST'):
+ """
+ Perform a generic request and return the raw text.
+
... 1884 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/mwclient.git
More information about the Python-modules-commits
mailing list