Revision: 5137 Author: btongminh Date: 2008-03-16 20:02:16 +0000 (Sun, 16 Mar 2008)
Log Message: ----------- Don't iterate on TTP or TSP if they are None. (patch by NicDumZ)
Modified Paths: -------------- trunk/pywikipedia/blockpageschecker.py
Modified: trunk/pywikipedia/blockpageschecker.py =================================================================== --- trunk/pywikipedia/blockpageschecker.py 2008-03-16 12:30:29 UTC (rev 5136) +++ trunk/pywikipedia/blockpageschecker.py 2008-03-16 20:02:16 UTC (rev 5137) @@ -161,14 +161,16 @@
def understandBlock(text, TTP, TSP, TSMP, TTMP): """ Understand if the page is blocked and if it has the right template """ - for catchRegex in TTP: # TTP = templateTotalProtection - resultCatch = re.findall(catchRegex, text) - if resultCatch != []: - return ('sysop-total', catchRegex) - for catchRegex in TSP: - resultCatch = re.findall(catchRegex, text) - if resultCatch != []: - return ('autoconfirmed-total', catchRegex) + if TTP: + for catchRegex in TTP: # TTP = templateTotalProtection + resultCatch = re.findall(catchRegex, text) + if resultCatch != []: + return ('sysop-total', catchRegex) + if TSP: + for catchRegex in TSP: + resultCatch = re.findall(catchRegex, text) + if resultCatch != []: + return ('autoconfirmed-total', catchRegex) if TSMP != None and TTMP != None and TTP != TTMP and TSP != TSMP: for catchRegex in TSMP: resultCatch = re.findall(catchRegex, text)
I asked bryan to make this commit because it's actually crashing for languages that don't have localized templates : Translate() defaults to 'en', and 'en' dictionary values are None, so it'll crash, trying to iterate on a None object. This fix is temporary, and can be reverted, once 'en' template names are properly configured.
2008/3/16, btongminh@svn.wikimedia.org btongminh@svn.wikimedia.org:
Revision: 5137 Author: btongminh Date: 2008-03-16 20:02:16 +0000 (Sun, 16 Mar 2008)
Log Message:
Don't iterate on TTP or TSP if they are None. (patch by NicDumZ)
Modified Paths:
trunk/pywikipedia/blockpageschecker.py
Modified: trunk/pywikipedia/blockpageschecker.py
--- trunk/pywikipedia/blockpageschecker.py 2008-03-16 12:30:29 UTC (rev 5136) +++ trunk/pywikipedia/blockpageschecker.py 2008-03-16 20:02:16 UTC (rev 5137) @@ -161,14 +161,16 @@
def understandBlock(text, TTP, TSP, TSMP, TTMP): """ Understand if the page is blocked and if it has the right template """
- for catchRegex in TTP: # TTP = templateTotalProtection
resultCatch = re.findall(catchRegex, text)
if resultCatch != []:
return ('sysop-total', catchRegex)
- for catchRegex in TSP:
resultCatch = re.findall(catchRegex, text)
if resultCatch != []:
return ('autoconfirmed-total', catchRegex)
- if TTP:
for catchRegex in TTP: # TTP = templateTotalProtection
resultCatch = re.findall(catchRegex, text)
if resultCatch != []:
return ('sysop-total', catchRegex)
- if TSP:
for catchRegex in TSP:
resultCatch = re.findall(catchRegex, text)
if resultCatch != []:
if TSMP != None and TTMP != None and TTP != TTMP and TSP != TSMP: for catchRegex in TSMP: resultCatch = re.findall(catchRegex, text)return ('autoconfirmed-total', catchRegex)
Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
I am also being reported errors : http://fr.wikipedia.org/w/index.php?title=Esp%C3%A9ranto&diff=27446676&a... Espéranto is still protected...
2008/3/16, Nicolas Dumazet nicdumz@gmail.com:
I asked bryan to make this commit because it's actually crashing for languages that don't have localized templates : Translate() defaults to 'en', and 'en' dictionary values are None, so it'll crash, trying to iterate on a None object. This fix is temporary, and can be reverted, once 'en' template names are properly configured.
2008/3/16, btongminh@svn.wikimedia.org btongminh@svn.wikimedia.org:
Revision: 5137 Author: btongminh Date: 2008-03-16 20:02:16 +0000 (Sun, 16 Mar 2008)
Log Message:
Don't iterate on TTP or TSP if they are None. (patch by NicDumZ)
Modified Paths:
trunk/pywikipedia/blockpageschecker.py
Modified: trunk/pywikipedia/blockpageschecker.py
--- trunk/pywikipedia/blockpageschecker.py 2008-03-16 12:30:29 UTC (rev 5136) +++ trunk/pywikipedia/blockpageschecker.py 2008-03-16 20:02:16 UTC (rev 5137) @@ -161,14 +161,16 @@
def understandBlock(text, TTP, TSP, TSMP, TTMP): """ Understand if the page is blocked and if it has the right template """
- for catchRegex in TTP: # TTP = templateTotalProtection
resultCatch = re.findall(catchRegex, text)
if resultCatch != []:
return ('sysop-total', catchRegex)
- for catchRegex in TSP:
resultCatch = re.findall(catchRegex, text)
if resultCatch != []:
return ('autoconfirmed-total', catchRegex)
- if TTP:
for catchRegex in TTP: # TTP = templateTotalProtection
resultCatch = re.findall(catchRegex, text)
if resultCatch != []:
return ('sysop-total', catchRegex)
- if TSP:
for catchRegex in TSP:
resultCatch = re.findall(catchRegex, text)
if resultCatch != []:
if TSMP != None and TTMP != None and TTP != TTMP and TSP != TSMP: for catchRegex in TSMP: resultCatch = re.findall(catchRegex, text)return ('autoconfirmed-total', catchRegex)
Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
-- Nicolas Dumazet — NicDumZ Deuxième année ENSIMAG.