From patchwork Fri Sep 11 15:54:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Lespiau X-Patchwork-Id: 516852 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 97E8F140180 for ; Sat, 12 Sep 2015 01:56:55 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 7C9E21A2BC1 for ; Sat, 12 Sep 2015 01:56:55 +1000 (AEST) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lists.ozlabs.org (Postfix) with ESMTP id 2A50A1A0790 for ; Sat, 12 Sep 2015 01:55:33 +1000 (AEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 11 Sep 2015 08:55:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,511,1437462000"; d="scan'208";a="559866918" Received: from jeffzhua-mobl.amr.corp.intel.com (HELO strange.amr.corp.intel.com) ([10.254.88.85]) by FMSMGA003.fm.intel.com with ESMTP; 11 Sep 2015 08:55:32 -0700 From: Damien Lespiau To: patchwork@lists.ozlabs.org Subject: [PATCH 07/51] parsemail: Strip mail signatures from comments Date: Fri, 11 Sep 2015 16:54:40 +0100 Message-Id: <1441986924-26689-8-git-send-email-damien.lespiau@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1441986924-26689-1-git-send-email-damien.lespiau@intel.com> References: <1441986924-26689-1-git-send-email-damien.lespiau@intel.com> X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Those signature don't really add value to the comment. Signed-off-by: Damien Lespiau --- patchwork/bin/parsemail.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/patchwork/bin/parsemail.py b/patchwork/bin/parsemail.py index a622187..873415d 100755 --- a/patchwork/bin/parsemail.py +++ b/patchwork/bin/parsemail.py @@ -149,7 +149,6 @@ def find_pull_request(content): return match.group(1) return None - def try_decode(payload, charset): try: payload = unicode(payload, charset) @@ -157,6 +156,20 @@ def try_decode(payload, charset): return None return payload +def strip_signature(text): + if not text: + return + + buf = '' + for line in text.splitlines(True): + if line == '-- \n': + break + buf += line + + if buf == '': + return None + return buf.strip() + class MailContent: def __init__(self): self.patch = None @@ -245,6 +258,8 @@ def find_content(project, mail): if c is not None: commentbuf += c.strip() + '\n' + commentbuf = strip_signature(commentbuf) + ret = MailContent() if pullurl or patchbuf: