4 Mwclient is a client to the `MediaWiki API <//mediawiki.org/wiki/API>`_
5 which provides access to most API functionality.
6 It depends heavily on Bob Ippolito's `SimpleJSON <//github.com/simplejson/simplejson>`_,
7 requires Python 2.4 and supports MediaWiki 1.11 and above.
8 For functions not available in the current MediaWiki, a ``MediaWikiVersionError`` is raised.
10 This framework was written by Bryan Tong Minh, who released the latest stable
11 `version 0.6.5 <//github.com/mwclient/mwclient/archive/REL_0_6_5.zip>`_ on 6 May 2011.
12 The current `development version <//github.com/mwclient/mwclient>`_
13 can be installed directly off github:
15 .. code-block:: console
17 $ pip install git+git://github.com/mwclient/mwclient.git
19 Please see the `release notes <//github.com/mwclient/mwclient/blob/master/RELEASE-NOTES.md>`_
20 for a list of changes.
25 Most properties and generators accept the same parameters as the API,
26 without their two-letter prefix. Exceptions to this rule:
28 * ``Image.imageinfo`` is the imageinfo of the latest image.
29 Earlier versions can be fetched using ``imagehistory()``
30 * ``Site.all*``: parameter ``[ap]from`` renamed to ``start``
31 * ``categorymembers`` is implemented as ``Category.members``
32 * ``deletedrevs`` is ``deletedrevisions``
33 * ``usercontribs`` is ``usercontributions``
34 * First parameters of ``search`` and ``usercontributions`` are ``search`` and ``user``
37 Properties and generators are implemented as Python generators.
38 Their limit parameter is only an indication of the number of items in one chunk.
39 It is not the total limit.
40 Doing ``list(generator(limit = limit))`` will return ALL items of generator,
41 and not be limited by the limit value.
42 Default chunk size is generally the maximum chunk size.
48 To use https, specify the host as a tuple in the form of ``('https', hostname)``.
54 For more information, see the
55 `REFERENCE.md <//github.com/mwclient/mwclient/blob/master/REFERENCE.md>`_ file.
57 .. code-block:: python
59 # Initialize Site object
61 site = mwclient.Site('commons.wikimedia.org')
62 site.login(username, password) # Optional
65 page = site.Pages['Commons:Sandbox']
67 print 'Text in sandbox:', text.encode('utf-8')
68 page.save(text + u'\nExtra data', summary = 'Test edit')
71 image = site.Images['Example.jpg']
72 print 'Image', image.name.encode('utf-8'), 'usage:'
73 for page in image.imageusage():
74 print 'Used:', page.name.encode('utf-8'), '; namespace', page.namespace
75 print 'Image info:', image.imageinfo
78 site.upload(open('file.jpg'), 'destination.jpg', 'Image description')
80 # Listing all categories (don't do this in reality)
81 for category in site.allcategories():