From nobody Mon Feb 9 12:24:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+52886+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52886+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578306945; cv=none; d=zohomail.com; s=zohoarc; b=GA7niDNAw6KQ5dZ/umA7tVmiMcZ7xYiP2J4Wm6ri7QVLO4LtIMdvdf7nWTVQG82zx+1l6EGigMkJ4rBDp9rg+PZ+rFATJOex2Zga6b1zzSZEWBktAx9B/XU+SDUATov3mbEkc25IYvlqCi69DAUccLqh1Jw1rrPNuml+wqQVRCA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578306945; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=yRv2aiyUpwnMfv3xchPAeEWTzCXB2S2vaN2YQwbyczA=; b=AzKq0WYjLrGhVZVqpWd+MaRv0h6CPIhxjdv+KguCqZvKvkFKkCY48edmL5ArEQlbCdKWOrrIbn1L9EAbWmV7C2K+SiHAo6Ir2jaeKv+twnEHn3dz0fQZPOj0NF1mBTeUO7f5mk9SHLlLIT6k4WgXtqTfsjQ36v23sjmXR3f/BTI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52886+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 157830694548678.14380753326316; Mon, 6 Jan 2020 02:35:45 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id AwYIYY1788612xcLHg3M2CKd; Mon, 06 Jan 2020 02:35:44 -0800 X-Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.120]) by mx.groups.io with SMTP id smtpd.web09.2046.1578306941879987166 for ; Mon, 06 Jan 2020 02:35:42 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-228-BFAzwaiqNemlCrUy0F2zQw-1; Mon, 06 Jan 2020 05:35:39 -0500 X-Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BABA1DB60; Mon, 6 Jan 2020 10:35:38 +0000 (UTC) X-Received: from x1w.redhat.com (ovpn-204-53.brq.redhat.com [10.40.204.53]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 78D2D5D9E1; Mon, 6 Jan 2020 10:35:36 +0000 (UTC) From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= To: devel@edk2.groups.io Cc: Michael D Kinney , Laszlo Ersek , Philippe Mathieu-Daude , Liming Gao , Jordan Justen Subject: [edk2-devel] [PATCH v2 1/4] BaseTools/PatchCheck.py: Extract email check code to EmailAddressCheck Date: Mon, 6 Jan 2020 11:35:25 +0100 Message-Id: <20200106103528.5438-2-philmd@redhat.com> In-Reply-To: <20200106103528.5438-1-philmd@redhat.com> References: <20200106103528.5438-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: BFAzwaiqNemlCrUy0F2zQw-1 X-Mimecast-Spam-Score: 0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,philmd@redhat.com X-Gm-Message-State: m1V1kbDtUL8IazatCOT3je3cx1787277AA= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1578306944; bh=zIacw745kfJyZ7xM5GI9ZpEJ5ZQ7ijCEjW75DDCcsJ8=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=LfgMl7/dB3Hs0dQZUh9hr+LhGp8sXqQTj8GGYLv/wJ9fXYFvmNhwsK66mqpkxANzaAo 9OgeyukSCdsBntWepN/107SXx1wrCzsf0YQCs/3cmD2TvzscQkhjlcLxThaFkGrM1exav SUAzCksAYzmDA3wRQ9pnCAbI411TM4dbAbQ= X-ZohoMail-DKIM: pass (identity @groups.io) As we are going to reuse this code out of the CommitMessageCheck class, extract it in a new class: EmailAddressCheck. Cc: Liming Gao Cc: Jordan Justen Signed-off-by: Philippe Mathieu-Daude --- BaseTools/Scripts/PatchCheck.py | 82 +++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 29 deletions(-) diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck= .py index 2a4e6f603e79..0e654345fcc8 100755 --- a/BaseTools/Scripts/PatchCheck.py +++ b/BaseTools/Scripts/PatchCheck.py @@ -22,6 +22,58 @@ class Verbose: SILENT, ONELINE, NORMAL =3D range(3) level =3D NORMAL =20 +class EmailAddressCheck: + """Checks an email address.""" + + def __init__(self, email): + self.ok =3D True + + if email is None: + self.error('Email address is missing!') + return + + self.check_email_address(email) + + def error(self, *err): + if self.ok and Verbose.level > Verbose.ONELINE: + print('The email address is not valid:') + self.ok =3D False + if Verbose.level < Verbose.NORMAL: + return + count =3D 0 + for line in err: + prefix =3D (' *', ' ')[count > 0] + print(prefix, line) + count +=3D 1 + + email_re1 =3D re.compile(r'(?:\s*)(.*?)(\s*)<(.+)>\s*$', + re.MULTILINE|re.IGNORECASE) + + def check_email_address(self, email): + email =3D email.strip() + mo =3D self.email_re1.match(email) + if mo is None: + self.error("Email format is invalid: " + email.strip()) + return + + name =3D mo.group(1).strip() + if name =3D=3D '': + self.error("Name is not provided with email address: " + + email) + else: + quoted =3D len(name) > 2 and name[0] =3D=3D '"' and name[-1] = =3D=3D '"' + if name.find(',') >=3D 0 and not quoted: + self.error('Add quotes (") around name with a comma: ' + + name) + + if mo.group(2) =3D=3D '': + self.error("There should be a space between the name and " + + "email address: " + email) + + if mo.group(3).find(' ') >=3D 0: + self.error("The email address cannot contain a space: " + + mo.group(3)) + class CommitMessageCheck: """Checks the contents of a git commit message.""" =20 @@ -121,38 +173,10 @@ class CommitMessageCheck: if s[2] !=3D ' ': self.error("There should be a space after '" + sig + ":'") =20 - self.check_email_address(s[3]) + EmailAddressCheck(s[3]) =20 return sigs =20 - email_re1 =3D re.compile(r'(?:\s*)(.*?)(\s*)<(.+)>\s*$', - re.MULTILINE|re.IGNORECASE) - - def check_email_address(self, email): - email =3D email.strip() - mo =3D self.email_re1.match(email) - if mo is None: - self.error("Email format is invalid: " + email.strip()) - return - - name =3D mo.group(1).strip() - if name =3D=3D '': - self.error("Name is not provided with email address: " + - email) - else: - quoted =3D len(name) > 2 and name[0] =3D=3D '"' and name[-1] = =3D=3D '"' - if name.find(',') >=3D 0 and not quoted: - self.error('Add quotes (") around name with a comma: ' + - name) - - if mo.group(2) =3D=3D '': - self.error("There should be a space between the name and " + - "email address: " + email) - - if mo.group(3).find(' ') >=3D 0: - self.error("The email address cannot contain a space: " + - mo.group(3)) - def check_signed_off_by(self): sob=3D'Signed-off-by' if self.msg.find(sob) < 0: --=20 2.21.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#52886): https://edk2.groups.io/g/devel/message/52886 Mute This Topic: https://groups.io/mt/69462074/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-