Skip to content

Commit c554a1a

Browse files
committed
Tagging 0.6.4
1 parent a45091f commit c554a1a

File tree

13 files changed

+2036
-0
lines changed

13 files changed

+2036
-0
lines changed

mwclient/README.txt

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
This files describes mwclient-0.6.4. The latest version is available in the
2+
subversion repository <https://mwclient.svn.sourceforge.net/svnroot/mwclient>
3+
and also browsable <http://mwclient.svn.sourceforge.net/viewvc/mwclient/>.
4+
5+
Mwclient is a client to the MediaWiki API <http://mediawiki.org/wiki/API>
6+
and allows access to almost all implemented API functions. Mwclient requires
7+
Python 2.4. This version supports MediaWiki 1.11 and above. However, for
8+
functions not available in the current MediaWiki, a MediaWikiVersionError
9+
is raised.
10+
11+
This framework is written by Bryan Tong Minh and serves most of his bots.
12+
The framework and this documentation are primarily written for personal
13+
use and may or may not work for you. In case it doesn't, Bryan can be
14+
contacted on [email protected].
15+
16+
This framework heavily depends on simplejson, (c) copyright Bob Ippolito.
17+
18+
19+
== Implementation notes ==
20+
Most properties and generators accept the same parameters as the API, without
21+
their two letter prefix. Exceptions to this rule:
22+
* Image.imageinfo is the imageinfo of the latest image. Earlier versions can be
23+
fetched using imagehistory()
24+
* Site.all* : parameter [ap]from renamed to start
25+
* categorymembers is implemented as Category.members
26+
* deletedrevs is deletedrevisions
27+
* usercontribs is usercontributions
28+
* First parameters of search and usercontributions are search and user
29+
respectively
30+
31+
Properties and generators are implemented as Python generators. Their limit
32+
parameter is only an indication of the number of items in one chunk. It is not
33+
the total limit. Doing list(generator(limit = limit)) will return ALL items of
34+
generator, and not be limited by the limit value.
35+
Default chunk size is generally the maximum chunk size.
36+
37+
== HTTPS ==
38+
To use https, specify the host as a tuple in the form of ('https', hostname).
39+
40+
== Example ==
41+
## For more information, see REFERENCE.txt
42+
# Init site object
43+
import mwclient
44+
site = mwclient.Site('commons.wikimedia.org')
45+
site.login(username, password) # Optional
46+
47+
# Edit page
48+
page = site.Pages['Commons:Sandbox']
49+
text = page.edit()
50+
print 'Text in sandbox:', text.encode('utf-8')
51+
page.save(text + u'\nExtra data', summary = 'Test edit')
52+
53+
# Printing imageusage
54+
image = site.Images['Example.jpg']
55+
print 'Image', image.name.encode('utf-8'), 'usage:'
56+
for page in image.imageusage():
57+
print 'Used:', page.name.encode('utf-8'), '; namespace', page.namespace
58+
print 'Image info:', image.imageinfo
59+
60+
# Uploading a file
61+
site.upload(open('file.jpg'), 'destination.jpg', 'Image description')
62+
63+
# Listing all categories (don't do this in reality)
64+
for category in site.allcategories():
65+
print category
66+
67+
== License ==
68+
Copyright (c) 2006-2009 Bryan Tong Minh
69+
70+
Permission is hereby granted, free of charge, to any person
71+
obtaining a copy of this software and associated documentation
72+
files (the "Software"), to deal in the Software without
73+
restriction, including without limitation the rights to use,
74+
copy, modify, merge, publish, distribute, sublicense, and/or sell
75+
copies of the Software, and to permit persons to whom the
76+
Software is furnished to do so, subject to the following
77+
conditions:
78+
79+
The above copyright notice and this permission notice shall be
80+
included in all copies or substantial portions of the Software.
81+
82+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
83+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
84+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
85+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
86+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
87+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
88+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
89+
OTHER DEALINGS IN THE SOFTWARE.

mwclient/REFERENCE.txt

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
This file is intended to be a reference to mwclient. The current version is
2+
mwclient 0.6.4.
3+
4+
The mwclient framework provides an access to the MediaWiki API. It provides the
5+
functions of the MediaWiki API in a Pythonic manner.
6+
7+
== Sites ==
8+
The 'Site' object is the most important class. It represents a MediaWiki site.
9+
Its constructor accepts various arguments, of which the first two, host and
10+
path are the most important. They represent respectively the hostname without
11+
protocol and the root directory where api.php is located. The path parameter
12+
should end with a slash /. Other protocols than HTTP are currently not
13+
supported.
14+
15+
site = mwclient.Site(host, path = '/w/', ...)
16+
17+
=== Pages ===
18+
Sites provide access to pages via various generators and the Pages object. The
19+
base Page object is called Page and from that derive Category and Image. When
20+
the page is retrieved via Site.Pages or a generator, it will check
21+
automatically which of those three specific types should be returned. To get
22+
a page by its name, call Site.Pages as a scriptable object:
23+
24+
page = site.Pages['Template:Stub']
25+
image = site.Pages['Image:Wiki.png'] # This will return an Image object
26+
image2 = site.Images['Wiki.png'] # The same image
27+
28+
Alternatively Site.Images and Site.Categories are provided, which do exactly
29+
the same as Site.Pages, except that they require the page name without its
30+
namespace prefixed.
31+
32+
==== PageProperties ====
33+
The Page object provides many generators available in the API. In addition to
34+
the page properties listed in the API documentation, also the lists backlinks
35+
and embeddedin are members of the Page object. See for more information about
36+
using generators the section about generators below.
37+
38+
Category objects provide an extra property members to list all members of the
39+
category. The Category object can also be used itself as an iterator yielding
40+
all its members.
41+
42+
category = site.Pages['Category:Help']
43+
for page in category:
44+
print category
45+
46+
Image objects have additional functions imagehistory and imageusage which
47+
represent the old images and the usage respectively. Image.download returns a
48+
file object to the full size image.
49+
50+
fr = image.download()
51+
fw = open('Wiki.png', 'rb')
52+
while True:
53+
s = fr.read(4096)
54+
if not s: break
55+
fw.write(s)
56+
fr.close() # Always close those file objects !!!
57+
fw.close()
58+
59+
==== Editting pages ====
60+
Call Page.edit() to retrieve the page content. Use Page.save(text, summary =
61+
u'', ...) to save the page. If available, Page.save uses the API to edit, but
62+
falls back to the old way if the write API is not available.
63+
64+
== Generators ==
65+
== Exceptions ==
66+
67+
== Implementation notes ==
68+
Most properties and generators accept the same parameters as the API, without
69+
their two letter prefix Exceptions:
70+
* Image.imageinfo is the imageinfo of the latest image. Earlier versions can be
71+
fetched using imagehistory()
72+
* Site.all* : parameter (ap)from renamed to start
73+
* categorymembers is implemented as Category.members
74+
* deletedrevs is deletedrevisions
75+
* usercontribs is usercontributions
76+
* First parameters of search and usercontributions are search and user
77+
respectively
78+
79+
Properties and generators are implemented as Python generators. Their limit
80+
parameter is only an indication of the number of items in one chunk. It is not
81+
the total limit. Doing list(generator(limit = limit)) will return ALL items of
82+
generator, and not be limitted by the limit value. Use list(generator(
83+
max_items = max_items)) to limit the amount of items returned.
84+
Default chunk size is generally the maximum chunk size.
85+
86+
== Links ==
87+
* SourceForge.net project: http://sourceforge.net/projects/mwclient
88+
* Project website: http://mwclient.sourceforge.net/
89+
* Subversion: https://mwclient.svn.sourceforge.net/svnroot/mwclient
90+
* Browseable repository: http://mwclient.svn.sourceforge.net/viewvc/mwclient/
91+
* MediaWiki API documentation: http://mediawiki.org/wiki/API

mwclient/RELEASE-NOTES.txt

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
RELEASE NOTES FOR MWCLIENT
2+
3+
This is mwclient 0.6.4. The following are the release notes for this version.
4+
5+
== Changes in version 0.6.4 ==
6+
Mwclient 0.6.4 is unreleased.
7+
* Added support for upload API
8+
* Added prop=duplicatefiles
9+
* Properly fix detection of alpha versions
10+
* Added support for builtin json library
11+
* Handle badtoken once
12+
* Bug 2690034: Fix revision iteration
13+
* Fix module conflict with simplejson-1.x by inserting mwclient path at the
14+
beginning of sys.path instead of the end
15+
* Supply token on login if necessary
16+
17+
== Changes in version 0.6.3 ==
18+
* Added domain parameter to login.
19+
* Applied edit fix to page_nowriteapi
20+
* Allow arbitrary data to be passed to page.save
21+
* Fix mwclient on WMF wikis
22+
23+
== Changes in version 0.6.2 ==
24+
Mwclient was released on 2 May 2009.
25+
* Compatibility fixes for MediaWiki 1.13
26+
* Download fix for images
27+
* Full support for editing pages via write api and split of compatibility to
28+
another file.
29+
* Added expandtemplates api call
30+
* Added and fixed moving via API
31+
* Raise an ApiDisabledError is the API is disabled
32+
* Added support for HTTPS
33+
* Fixed email code
34+
* Mark edits as bots by default.
35+
* Added action=parse. Modified patch by Brian Mingus.
36+
* Improved general HTTP and upload handling.
37+
38+
== Changes in version 0.6.1 and 0.6.0 ==
39+
Mwclient 0.6.1 was released in May 2008. No release notes were kept for
40+
that version.
41+
42+
Mwclient 0.6.0 was released in February 2008. It was the first official
43+
release via Sourceforge. This version removed some Pywikipedia influences
44+
added in 0.4.
45+
46+
== Mwclient 0.5 ==
47+
Mwclient 0.5 was an architectural redesign which accomplished easy
48+
extendibility and added proper support for continuations.
49+
50+
== Mwclient 0.4 ==
51+
Mwclient 0.4 was somewhat the basis for future releases and shows the current
52+
module architecture. It was influenced by Pywikipedia that was by then
53+
discovered by the author.
54+
55+
== Mwclient 0.2 and 0.3 ==
56+
Mwclient 0.2 and 0.3 were probably a bit of a generalization, and maybe
57+
already used the API for some part, but details are unknown.
58+
59+
== Mwclient 0.1 ==
60+
Mwclient 0.1 was a non-API module for accessing Wikipedia using an XML parser.

mwclient/__init__.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""
2+
Copyright (c) 2006-2008 Bryan Tong Minh
3+
4+
Permission is hereby granted, free of charge, to any person
5+
obtaining a copy of this software and associated documentation
6+
files (the "Software"), to deal in the Software without
7+
restriction, including without limitation the rights to use,
8+
copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the
10+
Software is furnished to do so, subject to the following
11+
conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
OTHER DEALINGS IN THE SOFTWARE.
24+
"""
25+
26+
import sys as _sys
27+
import os as _os
28+
_path = _os.path.dirname(__file__)
29+
_sys.path.insert(0, _os.path.abspath(_path))
30+
31+
from errors import *
32+
from client import Site, __ver__
33+
import ex

0 commit comments

Comments
 (0)