[Pywikipedia-svn] SVN: [7229] trunk/pywikipedia/userlib.py

alexsh at svn.wikimedia.org alexsh at svn.wikimedia.org
Sat Sep 12 16:22:12 UTC 2009


Revision: 7229
Author:   alexsh
Date:     2009-09-12 16:22:12 +0000 (Sat, 12 Sep 2009)

Log Message:
-----------
userlib.py:fix block() and unblock() data message i18n

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

Modified: trunk/pywikipedia/userlib.py
===================================================================
--- trunk/pywikipedia/userlib.py	2009-09-12 09:18:21 UTC (rev 7228)
+++ trunk/pywikipedia/userlib.py	2009-09-12 16:22:12 UTC (rev 7229)
@@ -148,7 +148,8 @@
 
             yield wikipedia.ImagePage(self.site, image), date, comment, deleted
 
-    def block(self, expiry=None, reason=None, anonOnly=True, noSignup=False, enableAutoblock=False, emailBan=False, watchUser=False, allowUsertalk=True):
+    def block(self, expiry=None, reason=None, anonOnly=True, noSignup=False,
+                enableAutoblock=False, emailBan=False, watchUser=False, allowUsertalk=True):
         """
         Block the user.
 
@@ -199,9 +200,9 @@
         response, data = self.site.postForm(address, predata, sysop = True)
 
         if data:
-            # TODO: i18n
-            if u'is already blocked' in data:
+            if self.site.mediawiki_message('ipb_already_blocked').replace('$1', self.name) in data:
                 raise AlreadyBlockedError
+            
             raise BlockError
         return True
 
@@ -223,7 +224,6 @@
     def _getBlockID(self):
         wikipedia.output(u"Getting block id for [[User:%s]]..." % self.name)
 
-        token = self.site.getToken(self, sysop = True)
         address = self.site.blocksearch_address(self.name)
         data = self.site.getUrl(address)
         bIDre = re.search(r'action=unblock&id=(\d+)', data)
@@ -248,8 +248,7 @@
 
         response, data = self.site.postForm(address, predata, sysop = True)
         if response.status != 302:
-            # TODO: i18n
-            if re.search('Block ID \d+ not found', data):
+            if self.site.mediawiki_message('ipb_cant_unblock').replace('$1',blockID) in data:
                 raise AlreadyUnblockedError
             raise UnblockError, data
         return True





More information about the Pywikipedia-svn mailing list