http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11472

Revision: 11472
Author:   legoktm
Date:     2013-04-27 11:27:20 +0000 (Sat, 27 Apr 2013)
Log Message:
-----------
Convert raw MediaWiki timestamps to pywikibot.Timestamp in 
Page.getVersionHistory and User.contributions

This makes it easier to manipulate timestamps, and you don't have to worry
about what format you'll get them in. I also added this to 
README-conversion.txt.

Modified Paths:
--------------
    branches/rewrite/README-conversion.txt
    branches/rewrite/pywikibot/page.py

Modified: branches/rewrite/README-conversion.txt
===================================================================
--- branches/rewrite/README-conversion.txt      2013-04-27 11:17:54 UTC (rev 
11471)
+++ branches/rewrite/README-conversion.txt      2013-04-27 11:27:20 UTC (rev 
11472)
@@ -88,6 +88,10 @@
 - removeImage()
 - replaceImage()
 
+The following methods have had their outputs changed:
+
+- getVersionHistory(): Returns a pywikibot.Timestamp object instead of a 
MediaWiki one
+
 === ImagePage objects ===
 
 For ImagePage objects, the getFileMd5Sum() method is deprecated; it is
@@ -107,4 +111,14 @@
 - supercategories: use self.categories() instead
 - supercategoriesList: use, for example, list(self.categories()) instead
 
+=== User objects ===
+
+The User object has been moved from the userlib module to the pywikibot
+namespace. Any references to "userlib.User" can be replaced by
+"pywikibot.User", but the old for mis retained for backwards-compatibility.
+
+The following changes have occured in the User object:
+
+- contributions(): returns a pywikibot.Timestamp object instead of a Mediawiki 
one
+
 # MORE TO COME #

Modified: branches/rewrite/pywikibot/page.py
===================================================================
--- branches/rewrite/pywikibot/page.py  2013-04-27 11:17:54 UTC (rev 11471)
+++ branches/rewrite/pywikibot/page.py  2013-04-27 11:27:20 UTC (rev 11472)
@@ -1115,7 +1115,7 @@
         self.site.loadrevisions(self, getText=False, rvdir=reverseOrder,
                                   step=step, total=total)
         return [ ( self._revisions[rev].revid,
-                   self._revisions[rev].timestamp,
+                   
pywikibot.Timestamp.fromtimestampformat(self._revisions[rev].timestamp),
                    self._revisions[rev].user,
                    self._revisions[rev].comment
                  ) for rev in sorted(self._revisions,
@@ -2188,7 +2188,6 @@
         for contrib in self.site.usercontribs(user=self.username,
                                         namespaces=namespaces, total=total):
             ts = pywikibot.Timestamp.fromISOformat(contrib['timestamp'])
-            ts = int(ts.strftime("%Y%m%d%H%M%S"))
             yield Page(self.site, contrib['title'], contrib['ns']), \
                   contrib['revid'], ts, contrib.get('comment', None)
 


_______________________________________________
Pywikipedia-svn mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-svn

Reply via email to