[libcamera-devel] [PATCH] utils: checkstyle.py: Fix color bleed
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Mon May 30 10:22:11 CEST 2022
Hi Tomi,
Thank you for the patch.
On Mon, May 30, 2022 at 10:22:28AM +0300, Tomi Valkeinen wrote:
> If issue.line is None, the the terminal color is never reset back to
> normal. This causes the yellow color to bleed.
>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen at ideasonboard.com>
> ---
> utils/checkstyle.py | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/utils/checkstyle.py b/utils/checkstyle.py
> index 835f2a9f..fa0513f2 100755
> --- a/utils/checkstyle.py
> +++ b/utils/checkstyle.py
> @@ -743,9 +743,9 @@ def check_file(top_level, commit, filename):
> if len(issues):
> issues = sorted(issues, key=lambda i: i.line_number)
> for issue in issues:
> - print('%s#%u: %s' % (Colours.fg(Colours.Yellow), issue.line_number, issue.msg))
> + print('%s#%u: %s%s' % (Colours.fg(Colours.Yellow), issue.line_number, issue.msg, Colours.reset()))
This could be wrapped.
> if issue.line is not None:
> - print('+%s%s' % (issue.line.rstrip(), Colours.reset()))
> + print('%s+%s%s' % (Colours.fg(Colours.Yellow), issue.line.rstrip(), Colours.reset()))
I think I would have added
sys.stdout.write(Colours.reset())
here (and dropped it from the previous line) to avoid outputting it
twice, but that makes no big difference. Either way,
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
>
> return len(formatted_diff) + len(issues)
>
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list