From nobody Tue May 13 12:35:50 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 153294745243852.49670890213167; Mon, 30 Jul 2018 03:44:12 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 18AA9308625F; Mon, 30 Jul 2018 10:44:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 03FC4173C3; Mon, 30 Jul 2018 10:44:11 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E645218037EC; Mon, 30 Jul 2018 10:44:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6UAi8JG001324 for ; Mon, 30 Jul 2018 06:44:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 02ACB2026D76; Mon, 30 Jul 2018 10:44:08 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-116-217.ams2.redhat.com [10.36.116.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id 865762026D68 for ; Mon, 30 Jul 2018 10:44:07 +0000 (UTC) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Mon, 30 Jul 2018 12:44:05 +0200 Message-Id: <20180730104406.22997-2-pbonzini@redhat.com> In-Reply-To: <20180730104406.22997-1-pbonzini@redhat.com> References: <20180730104406.22997-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 1/2] tags: use regex to match tags X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 30 Jul 2018 10:44:11 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This is simpler, since we can use case insensitive matches, and will also be easier to reuse in the next patch. Signed-off-by: Paolo Bonzini --- mods/tags.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mods/tags.py b/mods/tags.py index 5ec5bc2..aa29c60 100644 --- a/mods/tags.py +++ b/mods/tags.py @@ -13,6 +13,8 @@ from mbox import parse_address from event import register_handler, emit_event, declare_event from api.models import Message from api.rest import PluginMethodField +from patchew.tags import lines_iter +import re =20 REV_BY_PREFIX =3D "Reviewed-by:" BASED_ON_PREFIX =3D "Based-on:" @@ -55,6 +57,11 @@ series cover letter, patch mail body and their replies. tagsconfig =3D self.get_config("default", "tags", default=3D"") return set([x.strip() for x in tagsconfig.split(",") if x.strip()]= + BUILT_IN_TAGS) =20 + def get_tag_regex(self): + tags =3D self.get_tag_prefixes() + tags_re =3D '|'.join(map(re.escape, tags)) + return re.compile('^(?i:%s):' % tags_re) + def update_tags(self, s): old =3D s.get_property("tags", []) new =3D self.look_for_tags(s) @@ -105,10 +112,10 @@ series cover letter, patch mail body and their replie= s. =20 def parse_message_tags(self, m): r =3D [] + regex =3D self.get_tag_regex() for l in m.get_body().splitlines(): - for p in self.get_tag_prefixes(): - if l.lower().startswith(p.lower()): - r.append(l) + if regex.match(l): + r.append(l) return r =20 def look_for_tags(self, m): --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel