[Pywikipedia-l] SVN: [5328] branches/rewrite/pywikibot/site.py

nicdumz at svn.wikimedia.org nicdumz at svn.wikimedia.org
Wed May 7 23:23:11 UTC 2008


Revision: 5328
Author:   nicdumz
Date:     2008-05-07 23:23:11 +0000 (Wed, 07 May 2008)

Log Message:
-----------
Adding Site.getcurrenttimestamp() , useful for Special:Log which is now relying on timestamps

Modified Paths:
--------------
    branches/rewrite/pywikibot/site.py

Modified: branches/rewrite/pywikibot/site.py
===================================================================
--- branches/rewrite/pywikibot/site.py	2008-05-07 22:58:16 UTC (rev 5327)
+++ branches/rewrite/pywikibot/site.py	2008-05-07 23:23:11 UTC (rev 5328)
@@ -20,6 +20,7 @@
 import os
 import sys
 import threading
+import re
 
 
 class PageInUse(pywikibot.Error):
@@ -428,6 +429,16 @@
             self._userinfo = uidata['query']['userinfo']
         return self._userinfo
 
+    def getcurrenttimestamp(self):
+        """Returns a (Mediawiki) timestamp, {{CURRENTTIMESTAMP}},
+           the server time.
+           Format is yyyymmddhhmmss"""
+        r = api.Request(site=self,
+                        action="parse",
+                        text="{{CURRENTTIMESTAMP}}")
+        result = r.submit()
+        return re.search('\d+', result['parse']['text']['*']).group()
+
     def getsiteinfo(self):
         """Retrieve siteinfo from site and store in _siteinfo attribute."""
         if not hasattr(self, "_siteinfo"):





More information about the Pywikipedia-l mailing list