From 70c284bca9b6be658ce1aa1c15fe376631bb6910 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Mon, 30 Jul 2012 00:46:08 -0400 Subject: [PATCH] Hopefully, smarter handling of closed/resolved cases. --- earwigbot/tasks/drn_clerkbot.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/earwigbot/tasks/drn_clerkbot.py b/earwigbot/tasks/drn_clerkbot.py index cfba798..afca673 100644 --- a/earwigbot/tasks/drn_clerkbot.py +++ b/earwigbot/tasks/drn_clerkbot.py @@ -326,10 +326,14 @@ class DRNClerkBot(Task): close_age = (datetime.utcnow() - case.close_time).total_seconds() modify_age = (datetime.utcnow() - max(timestamps)).total_seconds() if closed_age > 60 * 60 * 24 and modify_age > 60 * 60 * 24: + arch_top = self.tl_archive_top + arch_bottom = self.tl_archive_bottom reg = "()?" - repl = "{{" + self.tl_archive_top + "}}" - case.body = re.sub(reg, repl, case.body) - case.body += "\n{{" + self.tl_archive_bottom + "}}" + if re.search(reg, case.body): + case.body = re.sub("\{\{" + arch_top + "\}\}", "", case.body) + case.body = re.sub(reg, "{{" + arch_top + "}}", case.body) + if not re.search(arch_bottom + "\s*\}\}\s*\Z", case.body): + case.body += "\n{{" + arch_bottom + "}}" case.status = self.STATUS_UNKNOWN def check_for_review(self, case):