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 <bob.c.f...@intel.com> Cc: Liming Gao <liming....@intel.com> Signed-off-by: Philippe Mathieu-Daude <phi...@redhat.com> --- 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) +if run_git('config', 'color.ui') != 'false': + # If the user configure git color.checkpatch.error and the termcolor package + # is available, display warnings using the requested color. + warning_color = run_git('config', 'color.checkpatch.error') + if warning_color: + try: + from termcolor import colored, cprint + _ = colored("check we can parse the color", warning_color.strip()) + def printw(line): + cprint(line, color=warning_color.strip(), attrs=['bold']) + except: + pass + class Verbose: SILENT, QUIET, ONELINE, NORMAL = range(4) level = NORMAL -- 2.21.0 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#51791): https://edk2.groups.io/g/devel/message/51791 Mute This Topic: https://groups.io/mt/67004111/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-