http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10311
Revision: 10311 Author: drtrigon Date: 2012-06-08 00:08:13 +0000 (Fri, 08 Jun 2012) Log Message: ----------- Page.append() added
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2012-06-07 23:45:48 UTC (rev 10310) +++ trunk/pywikipedia/wikipedia.py 2012-06-08 00:08:13 UTC (rev 10311) @@ -2513,6 +2513,41 @@
return response.code, response.msg, data
+ ## @since r10311 + # @remarks to support appending to single sections + def append(self, newtext, comment=None, minorEdit=True, section=0): + """Append the wiki-text to the page. + + Returns the result of text append to page section number 'section'. + 0 for the top section, 'new' for a new section (end of page). + """ + + # If no comment is given for the change, use the default + comment = comment or pywikibot.action + + # send data by POST request + params = { + 'action' : 'edit', + 'title' : self.title(), + 'section' : '%s' % section, + 'appendtext' : self._encodeArg(newtext, 'text'), + 'token' : self.site().getToken(), + 'summary' : self._encodeArg(comment, 'summary'), + 'bot' : 1, + } + + if minorEdit: + params['minor'] = 1 + else: + params['notminor'] = 1 + + response, data = query.GetData(params, self.site(), back_response = True) + + if not (data['edit']['result'] == u"Success"): + raise PageNotSaved('Bad result returned: %s' % data['edit']['result']) + + return response.code, response.msg, data + def protection(self): """Return list of dicts of this page protection level. like: [{u'expiry': u'2010-05-26T14:41:51Z', u'type': u'edit', u'level': u'autoconfirmed'}, {u'expiry': u'2010-05-26T14:41:51Z', u'type': u'move', u'level': u'sysop'}]
pywikipedia-svn@lists.wikimedia.org