From db59f2ba48f7672fc631c373d3f66ada1bfeaa4a Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Tue, 31 Jul 2012 21:00:59 -0400 Subject: [PATCH] Improve parsing rules for usernames in signatures. --- earwigbot/tasks/drn_clerkbot.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/earwigbot/tasks/drn_clerkbot.py b/earwigbot/tasks/drn_clerkbot.py index 3c8654a..f838bf6 100644 --- a/earwigbot/tasks/drn_clerkbot.py +++ b/earwigbot/tasks/drn_clerkbot.py @@ -141,7 +141,7 @@ class DRNClerkBot(Task): for line in text.splitlines(): user = re.search("\# \{\{User\|(.*?)\}\}", line) if user: - additions.add((user.group(1),)) + additions.add((user.group(1).replace("_", " ").strip(),)) removals = set() query1 = "SELECT volunteer_username FROM volunteers" @@ -355,7 +355,8 @@ class DRNClerkBot(Task): matches = re.findall(regex, text, re.U) signatures = [] for userlink, stamp in matches: - username = userlink.split("/", 1)[0].replace("_", " ") + username = userlink.split("/", 1)[0].replace("_", " ").strip() + stamp = stamp.strip() timestamp = datetime.strptime(stamp, "%H:%M, %d %B %Y (UTC)") signatures.append((username, timestamp)) return signatures @@ -380,7 +381,7 @@ class DRNClerkBot(Task): for line in text.group(1).splitlines(): user = re.search("[:*#]{,5} \{\{User\|(.*?)\}\}", line) if user: - party = user.group(1).strip() + party = user.group(1).replace("_", " ").strip() notice = _Notice("User talk:" + party, template, too_late) notices.append(notice)