[Pywikipedia-l] SVN: [6368] trunk/pywikipedia/wikipedia.py

filnik at svn.wikimedia.org filnik at svn.wikimedia.org
Wed Feb 18 15:49:34 UTC 2009


Revision: 6368
Author:   filnik
Date:     2009-02-18 15:49:34 +0000 (Wed, 18 Feb 2009)

Log Message:
-----------
New function, get last editor(s) 

Modified Paths:
--------------
    trunk/pywikipedia/wikipedia.py

Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py	2009-02-18 15:49:13 UTC (rev 6367)
+++ trunk/pywikipedia/wikipedia.py	2009-02-18 15:49:34 UTC (rev 6368)
@@ -2727,6 +2727,23 @@
         else:
             return new_text
 
+    def getLatestEditor(self, limit):
+        #action=query&prop=revisions&titles=API&rvprop=timestamp|user|comment
+        params = {
+            'action'    :'query',
+            'prop'      :'revisions',
+            'rvprop'    :'user|timestamp',
+            'rvlimit'   :limit,
+            'titles'    :self.title(),
+            }
+        data = query.GetData(params, useAPI = True, encodeTitle = False)
+        try:
+            # We don't know the page's id, if any other better idea please change it
+            pageid = data['query']['pages'].keys()[0]
+            nickdata = data['query']['pages'][pageid][u'revisions']
+            return nickdata
+        except KeyError:
+            raise NoPage(u'API Error, nothing found in the APIs')
 
 class ImagePage(Page):
     """A subclass of Page representing an image descriptor wiki page.
@@ -2851,7 +2868,7 @@
             return [nick, timestamp]
         except KeyError:
             raise NoPage(u'API Error, nothing found in the APIs')
-
+        
     def getHash(self):
         """ Function that return the Hash of an image in oder to understand if two
             Images are the same or not.





More information about the Pywikipedia-l mailing list