http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10232
Revision: 10232 Author: xqt Date: 2012-05-22 21:11:27 +0000 (Tue, 22 May 2012) Log Message: ----------- new getCreator method: function to get the first editor and time stamp of a page
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2012-05-20 19:56:01 UTC (rev 10231) +++ trunk/pywikipedia/wikipedia.py 2012-05-22 21:11:27 UTC (rev 10232) @@ -223,6 +223,8 @@ getVersionHistoryTable: Create a wiki table from the history data fullVersionHistory : Return all past versions including wikitext contributingUsers : Return set of users who have edited page + getCreator : Function to get the first editor of a page + getLatestEditors : Function to get the last editors of a page exists (*) : True if the page actually exists, false otherwise isEmpty (*) : True if the page has 4 characters or less content, not counting interwiki and category links @@ -1038,7 +1040,6 @@ """ return self._editTime
- def previousRevision(self): """Return the revision id for the previous revision of this Page.""" vh = self.getVersionHistory(revCount=2) @@ -2926,6 +2927,24 @@ users = set([edit[2] for edit in edits]) return users
+ def getCreator(self): + """ Function to get the first editor and time stamp of a page """ + inf = getVersionHistory(reverseOrder=True, revCount=1)[0] + return inf[2], inf[1] + + def getLatestEditors(self, limit=1): + """ Function to get the last editors of a page """ + #action=query&prop=revisions&titles=API&rvprop=timestamp|user|comment + if hasattr(self, '_versionhistory'): + data = self.getVersionHistory(getAll=True, revCount=limit) + else: + data = self.getVersionHistory(revCount = limit) + + result = [] + for i in data: + result.append({'user':i[2], 'timestamp':i[1]}) + return result + def watch(self, unwatch=False): """Add this page to the watchlist""" if self.site().has_api: @@ -3729,21 +3748,7 @@ else: return new_text
- def getLatestEditors(self, limit = 1): - """ Function to get the last editors of a page """ - #action=query&prop=revisions&titles=API&rvprop=timestamp|user|comment - if hasattr(self, '_versionhistory'): - data = self.getVersionHistory(getAll=True, revCount = limit) - else: - data = self.getVersionHistory(revCount = limit)
- result = [] - for i in data: - result.append({'user':i[2],'timestamp':i[1]}) - - return result - - class ImagePage(Page): """A subclass of Page representing an image descriptor wiki page.
pywikipedia-svn@lists.wikimedia.org