Revision: 8158
Author: shizhao
Date: 2010-05-12 15:29:13 +0000 (Wed, 12 May 2010)
Log Message:
-----------
new add protection().
Return list of dicts of this page protection level.
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2010-05-12 08:50:38 UTC (rev 8157)
+++ trunk/pywikipedia/wikipedia.py 2010-05-12 15:29:13 UTC (rev 8158)
@@ -241,6 +241,7 @@
getReferences : List of pages linking to the page
canBeEdited (*) : True if page is unprotected or user has edit
privileges
+ protection(*) : This page protection level
botMayEdit (*) : True if bot is allowed to edit page
put(newtext) : Saves the page
put_async(newtext) : Queues the page to be saved asynchronously
@@ -2115,6 +2116,25 @@
# page is locked and we don't have a sysop account.
return False
+ def protection(self):
+ """Return list of dicts of this page protection level. like:
+ [{u'expiry': u'2010-05-26T14:41:51Z', u'type': u'edit', u'level': u'autoconfirmed'}, {u'expiry': u'2010-05-26T14:41:51Z', u'type': u'move', u'level': u'sysop'}]
+
+ if the page non protection, return []
+ """
+
+ params = {
+ 'action': 'query',
+ 'prop' : 'info',
+ 'inprop': 'protection',
+ 'titles' : self.title(),
+ }
+
+ datas = query.GetData(params, self.site())
+ data=datas['query']['pages'].values()[0]['protection']
+ return data
+
+
def toggleTalkPage(self):
"""Return the other member of the article-talk page pair for this Page.
Revision: 8156
Author: russblau
Date: 2010-05-11 20:13:00 +0000 (Tue, 11 May 2010)
Log Message:
-----------
Fixing bugs identified on mailing list by Morten Wang.
Modified Paths:
--------------
branches/rewrite/pywikibot/login.py
Modified: branches/rewrite/pywikibot/login.py
===================================================================
--- branches/rewrite/pywikibot/login.py 2010-05-11 14:26:15 UTC (rev 8155)
+++ branches/rewrite/pywikibot/login.py 2010-05-11 20:13:00 UTC (rev 8156)
@@ -48,10 +48,10 @@
import logging
import pywikibot
-from pywikibot import config
+from pywikibot import config, deprecate_arg
from pywikibot.exceptions import NoSuchSite, NoUsername
-logger = "wiki.login"
+_logger = "wiki.login"
# On some wikis you are only allowed to run a bot if there is a link to
@@ -70,6 +70,8 @@
class LoginManager:
+ @deprecate_arg("username", "user")
+ @deprecate_arg("verbose", None)
def __init__(self, password=None, sysop=False, site=None, user=None):
if site is not None:
self.site = site
@@ -255,20 +257,22 @@
for lang in namedict[familyName]:
try:
site = pywikibot.getSite(code=lang, fam=familyName)
- if not forceLogin and (site.logged_in(sysop) and site.user()) != None:
- pywikibot.output(u'Already logged in on %s' % site)
+ if site.logged_in(sysop) \
+ and site.user() == site.username(sysop):
+ pywikibot.output(u"Login successful on %(site)s." % locals())
else:
- loginMan = LoginManager(password, sysop=sysop,
- site=site)
- loginMan.login()
+ pywikibot.output(u"Not logged in on %(site)s." % locals())
except NoSuchSite:
pywikibot.output(
lang + u'.' + familyName +
u' is not a valid site, please remove it from your config')
else:
- loginMan = pywikibot.data.api.LoginManager(password, sysop=sysop)
- loginMan.login()
+ site = pywikibot.Site(sysop=sysop)
+ if site.logged_in(sysop) and site.user() == site.username(sysop):
+ pywikibot.output(u"Login successful on %(site)s." % locals())
+ else:
+ pywikibot.output(u"Not logged in on %(site)s." % locals())
if __name__ == "__main__":
try:
Revision: 8155
Author: filnik
Date: 2010-05-11 14:26:15 +0000 (Tue, 11 May 2010)
Log Message:
-----------
Bugfix due to the change of timestamp
Modified Paths:
--------------
trunk/pywikipedia/checkimages.py
Modified: trunk/pywikipedia/checkimages.py
===================================================================
--- trunk/pywikipedia/checkimages.py 2010-05-10 17:50:47 UTC (rev 8154)
+++ trunk/pywikipedia/checkimages.py 2010-05-11 14:26:15 UTC (rev 8155)
@@ -1329,12 +1329,16 @@
if normal:
imageData = image
image = imageData[0]
- timestamp = imageData[1]
+ #20100511133318L --- 15:33, 11 mag 2010 e 18 sec
+ b = str(imageData[1]) # use b as variable to make smaller the timestamp-formula used below..
+ # fixing the timestamp to the format that we normally use..
+ timestamp = "%s-%s-%sT%s:%s:%sZ" % (b[0:4], b[4:6], b[6:8], b[8:10], b[10:12], b[12:14])
else:
+ #http://pytz.sourceforge.net/ <- maybe useful?
+ # '2008-06-18T08:04:29Z'
timestamp = image.getLatestUploader()[1]
- #http://pytz.sourceforge.net/ <- maybe useful?
- # '2008-06-18T08:04:29Z'
img_time = datetime.datetime.strptime(timestamp, u"%Y-%m-%dT%H:%M:%SZ") #not relative to localtime
+
now = datetime.datetime.strptime(str(datetime.datetime.utcnow()).split('.')[0], "%Y-%m-%d %H:%M:%S") #timezones are UTC
# + seconds to be sure that now > img_time
while now < img_time: