Revision: 6455 Author: nicdumz Date: 2009-02-28 22:47:55 +0000 (Sat, 28 Feb 2009)
Log Message: ----------- Deprecating family.server_time(), introducing Site.getcurrenttime()
Modified Paths: -------------- branches/rewrite/pywikibot/family.py branches/rewrite/pywikibot/site.py
Modified: branches/rewrite/pywikibot/family.py =================================================================== --- branches/rewrite/pywikibot/family.py 2009-02-28 17:06:03 UTC (rev 6454) +++ branches/rewrite/pywikibot/family.py 2009-02-28 22:47:55 UTC (rev 6455) @@ -7,7 +7,7 @@ import re import urllib
-from datetime import datetime, timedelta +import pywikibot
logger = logging.getLogger("wiki.family")
@@ -49,10 +49,10 @@ ]
self.langs = {} - # The timedelta to GMT of the server. - # Exemple for a server running CET : - # timedelta(hours=+1) - self.servergmtoffset = timedelta() +## # The timedelta to GMT of the server. +## # Exemple for a server running CET : +## # timedelta(hours=+1) +## self.servergmtoffset = timedelta()
# letters that can follow a wikilink and are regarded as part of # this link # This depends on the linktrail setting in LanguageXx.php and on # [[MediaWiki:Linktrail]]. @@ -1005,9 +1005,11 @@ return (None, None)
def server_time(self, code): - """Return a datetime object representing server time""" - # TODO : If the local computer time is wrong, result will be wrong - return datetime.utcnow() + self.servergmtoffset + """ + DEPRECATED, use Site.getcurrenttime() instead + Return a datetime object representing server time""" + pywikibot.deprecated("Site.getcurrenttime()") + return pywikibot.Site(code, self).getcurrenttime()
def isPublic(self, code): """Does the wiki require logging in before viewing it?"""
Modified: branches/rewrite/pywikibot/site.py =================================================================== --- branches/rewrite/pywikibot/site.py 2009-02-28 17:06:03 UTC (rev 6454) +++ branches/rewrite/pywikibot/site.py 2009-02-28 22:47:55 UTC (rev 6455) @@ -28,6 +28,7 @@ import sys import threading import urllib +from datetime import datetime
logger = logging.getLogger("wiki.site")
@@ -789,6 +790,11 @@ result = r.submit() return re.search('\d+', result['parse']['text']['*']).group()
+ def getcurrenttime(self): + """Returns a datetime object representing server time""" + ts = self.getcurrenttimestamp() + return datetime.strptime(ts, "%Y%m%d%H%M%S") + def _getsiteinfo(self): """Retrieve siteinfo and namespaces from site.""" sirequest = api.Request(
pywikipedia-l@lists.wikimedia.org