|
| 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 | + |
| 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. |
0 commit comments