From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.120]) by mx.groups.io with SMTP id smtpd.web12.11654.1575562380387106129 for ; Thu, 05 Dec 2019 08:13:00 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jNOdpzcR; spf=pass (domain: redhat.com, ip: 207.211.31.120, mailfrom: philmd@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575562379; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zMDYgGfBOIKY0rlz1jz5WKrduU20adl2a7VIXpIG5AI=; b=jNOdpzcRpkCEJ3JwbSOw1AUYExzkw97tGmbnVMofDTzq5AborFhSfQxXqEnoafe53BgpFz ocv+33mO0Apl4irmdm9Rj0IXMi7bCBxEKhkuyu2aPMAj+WJI9WxobmqXOZ3bnNQWWEn1y4 4GQRM8kMo7aCS+brAfudo2MNlX17yzQ= 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-321-UetMGdkdOaiEjzAlvj79xA-1; Thu, 05 Dec 2019 11:12:56 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 86D89DBE7; Thu, 5 Dec 2019 16:12:54 +0000 (UTC) Received: from x1w.redhat.com (ovpn-205-76.brq.redhat.com [10.40.205.76]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3C4A110013D9; Thu, 5 Dec 2019 16:12:53 +0000 (UTC) From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= To: devel@edk2.groups.io Cc: Philippe Mathieu-Daude , Bob Feng , Liming Gao Subject: [PATCH 6/6] BaseTools/PatchCheck: Allow to print colored warnings Date: Thu, 5 Dec 2019 17:12:34 +0100 Message-Id: <20191205161234.25071-7-philmd@redhat.com> In-Reply-To: <20191205161234.25071-1-philmd@redhat.com> References: <20191205161234.25071-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: UetMGdkdOaiEjzAlvj79xA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable If the user has the termcolor package installed, and he configured a 'color.checkpatch.error' color, use it to display colored warnings. Example to display warnings in red: $ git config color.checkpatch.error red Cc: Bob Feng Cc: Liming Gao Signed-off-by: Philippe Mathieu-Daude --- BaseTools/Scripts/PatchCheck.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck= .py index 5692f6eaf8bd..8e37311bd69a 100755 --- a/BaseTools/Scripts/PatchCheck.py +++ b/BaseTools/Scripts/PatchCheck.py @@ -32,6 +32,19 @@ def printw(line): """Print a warning to the console.""" print(line) =20 +if run_git('config', 'color.ui') !=3D 'false': + # If the user configure git color.checkpatch.error and the termcolor p= ackage + # is available, display warnings using the requested color. + warning_color =3D run_git('config', 'color.checkpatch.error') + if warning_color: + try: + from termcolor import colored, cprint + _ =3D colored("check we can parse the color", warning_color.st= rip()) + def printw(line): + cprint(line, color=3Dwarning_color.strip(), attrs=3D['bold= ']) + except: + pass + class Verbose: SILENT, QUIET, ONELINE, NORMAL =3D range(4) level =3D NORMAL --=20 2.21.0