Skip to content

Commit

Permalink
revertbot.py: Don't compare match/None with int
Browse files Browse the repository at this point in the history
It's not compatible with python 3.
Bug: T140506

Change-Id: I3f6dca1ae5cb743b75687e85e02c38610faf396b
  • Loading branch information
5j9 committed Jul 16, 2016
1 parent 20c3ca2 commit a8c8997
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions scripts/revertbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"""
#
# (C) Bryan Tong Minh, 2008
# (C) Pywikibot team, 2008-2015
# (C) Pywikibot team, 2008-2016
#
# Ported by Geoffrey "GEOFBOT" Mon - User:Sn1per
# for Google Code-In 2013
Expand Down Expand Up @@ -75,7 +75,7 @@ def get_contributions(self, max=500, ns=None):
yield item

def revert_contribs(self, callback=None):
"""Revert contrubutions."""
"""Revert contributions."""
if callback is None:
callback = self.callback

Expand All @@ -94,7 +94,7 @@ def revert_contribs(self, callback=None):
return

def callback(self, item):
"""Callback funktion."""
"""Callback function."""
return 'top' in item

def revert(self, item):
Expand Down Expand Up @@ -146,12 +146,18 @@ class myRevertBot(BaseRevertBot):
"""Example revert bot."""

def callback(self, item):
"""Callback funktion for 'private' revert bot."""
"""Callback function for 'private' revert bot.
@param item: an item from user contributions
@type item: dict
@rtype: bool
"""
if 'top' in item:
page = pywikibot.Page(self.site, item['title'])
text = page.get(get_redirect=True)
pattern = re.compile(r'\[\[.+?:.+?\..+?\]\]', re.UNICODE)
return pattern.search(text) >= 0
return bool(pattern.search(text))
return False


Expand Down

0 comments on commit a8c8997

Please sign in to comment.