Revision: 7121 Author: alexsh Date: 2009-08-06 18:10:15 +0000 (Thu, 06 Aug 2009)
Log Message: ----------- welcome.py.blocked(): make simple to return user is blocked
Modified Paths: -------------- trunk/pywikipedia/welcome.py
Modified: trunk/pywikipedia/welcome.py =================================================================== --- trunk/pywikipedia/welcome.py 2009-08-06 17:54:49 UTC (rev 7120) +++ trunk/pywikipedia/welcome.py 2009-08-06 18:10:15 UTC (rev 7121) @@ -497,22 +497,16 @@ #action=query&list=users&ususers=Filnik&usprop=blockinfo """ Function that detects if a user is currently blocked or not. - """ - + """ params = { - 'action' :'query', - 'list' :'users', - 'ususers' :username, - 'usprop' :'blockinfo', - } + 'action': 'query', + 'list': 'users', + 'ususers': username, + 'usprop': 'blockinfo', + }
- data = query.GetData(params, encodeTitle = False) # If there's not the blockedby parameter (that means the user isn't blocked), it will return False otherwise True. - try: - blockedBy = data['query']['users'][0]['blockedby'] - except KeyError: - return False # No he's not - return True # Yes is blocked + return query.GetData(params, encodeTitle = False)['query']['users'][0].has_key('blockedby')
def defineSign(wsite, signPageTitle, fileSignName = None, fileOption = False): """ Function to load the random signatures. """
pywikipedia-svn@lists.wikimedia.org