From patchwork Sat Jan 3 20:04:33 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1220 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767470742; bh=jGLybr+ZAfFbAWN1o8q5X/1zRLw66hTyauA9J/Yq/6A=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Mj+POg4aiy72L2mdPALt1HigfodsirntKG08WMgMNEa3/V5THHJFyFEX0qcoGwBx3 b3QSIqIZCxq+OKNd8PoKwCx17RiH/rsGvo7gelgczn961PQtCcxz7o5MxUdoTPK7zm YJL+qIHMl8Y/qFCDDAW8TuwhhTbW2H2DalXCo08p4vRSmfjs+IKI2/fPKHphxFWsSF uskkGWTSoDBwuB5HdGYAndXm9gTzUh4ZKCm5nR0HKgi6VR1bmUmwxerG5E2tXi8uv/ tbh4wDg2BrNNBMlHo75oOiatvyWMO6M5o53d9x3PHAL+oDZ8XS5KEQYeSLdK6ThCGz XneT+mN8ufBZg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 204736907B for ; Sat, 3 Jan 2026 13:05:42 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id vUEi-s1CPgBV for ; Sat, 3 Jan 2026 13:05:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767470742; bh=jGLybr+ZAfFbAWN1o8q5X/1zRLw66hTyauA9J/Yq/6A=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Mj+POg4aiy72L2mdPALt1HigfodsirntKG08WMgMNEa3/V5THHJFyFEX0qcoGwBx3 b3QSIqIZCxq+OKNd8PoKwCx17RiH/rsGvo7gelgczn961PQtCcxz7o5MxUdoTPK7zm YJL+qIHMl8Y/qFCDDAW8TuwhhTbW2H2DalXCo08p4vRSmfjs+IKI2/fPKHphxFWsSF uskkGWTSoDBwuB5HdGYAndXm9gTzUh4ZKCm5nR0HKgi6VR1bmUmwxerG5E2tXi8uv/ tbh4wDg2BrNNBMlHo75oOiatvyWMO6M5o53d9x3PHAL+oDZ8XS5KEQYeSLdK6ThCGz XneT+mN8ufBZg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0F0866908D for ; Sat, 3 Jan 2026 13:05:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767470740; bh=UEtTo8HpEg5enkyZZZ8oyHTPKnzrMuLy3wkzPmgKvW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LveQRUk7kXuyczA/hYxPRT9lMNL+NBi9qSxyEPJAFVBHn/Ka2IvRfL22gV2sd9N4L 6NLZOi+8mnfiT4zHs+FfTcMfYVbnw9zlw1tv/6BN2ETOdGyXAvTh1BRM3EtAL472FD Epf2XvQcqiAfMkkdKG8AnIBl0+VsY6U/ExuZsHvtH0ehdakSFtx1f4k3EDQsXdsagL +POR+E+RUtMrcCYAQT0/+y5OpodA2A1vFIXZwe511cUgpcdxDjw1rR3Ag4MAhxub6y EfBOJCNqsdwOubbnYdpe5NeTFUEfD8J8pxJdUArra/dJJXZQWsVblYP5pSAIADTlzd C8sKb5Mv4DIiw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 18C1D69060; Sat, 3 Jan 2026 13:05:40 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id puSkfZHupBFP; Sat, 3 Jan 2026 13:05:40 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767470735; bh=EgsWMvH2B3E3Gv8jSKjFZ9tWqopneQVertiYzUsnloo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VeQghGiPq0mc1wg7k+6Bh/A/4wd9327yT61I2uBNXGqDQ9uE93W4brQlzu8J+uybs vLI1rsb8DH1Fi0XyEJKd8VDC8mvEyxoeH2Z+vhaHZa8Lv6v8jn8T6lsdyoHpP7R+o/ SbyHaYPmHmoywYZjTPAjP3TIwHgXShZ/l6cpupS81p0pVFmZB+82IeSC5xMQhgBIZw hDeu+qGtI571ni3qhyMTVaxKaj0y791hEGdMOeS/egVIvwqrgecCtTYpeXUBAufE2w 60qtVTgOMh2ml0NjMQk2FXDGtGuj0EgmHIPml/h4/cAEu3Up3dBM2r7I73huul8ObP JAwnzI/bxQJHQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5CB176907B; Sat, 3 Jan 2026 13:05:35 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 3 Jan 2026 13:04:33 -0700 Message-ID: <20260103200510.3605009-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260103200510.3605009-1-sjg@u-boot.org> References: <20260103200510.3605009-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: R6NSBM6QZ2EJE2V34PVLKCN54GPLZCCR X-Message-ID-Hash: R6NSBM6QZ2EJE2V34PVLKCN54GPLZCCR X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 02/29] u_boot_pylib: tout: Add newline parameter to output functions List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add a newline parameter to all output functions (info, error, warning, notice, detail, debug, user_output, do_output) to allow suppressing the trailing newline. This is useful for progress output where multiple calls should appear on the same line. Example: tout.info('Processing...', newline=False) tout.info('done') Also fix typos in docstrings (msg; -> msg:). Signed-off-by: Simon Glass --- (no changes since v1) tools/u_boot_pylib/tout.py | 70 ++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/tools/u_boot_pylib/tout.py b/tools/u_boot_pylib/tout.py index 137b55edfd0..c608806476c 100644 --- a/tools/u_boot_pylib/tout.py +++ b/tools/u_boot_pylib/tout.py @@ -62,98 +62,108 @@ def progress(msg, warning=False, trailer='...'): else: terminal.tprint(_progress) -def _output(level, msg, color=None): +def _output(level, msg, color=None, newline=True): """Output a message to the terminal. Args: level: Verbosity level for this message. It will only be displayed if this as high as the currently selected level. - msg; Message to display. - error: True if this is an error message, else False. + msg: Message to display. + color: Colour to use for the text, None for default. + newline: True to add a newline at the end. """ if verbose >= level: clear_progress() if level <= WARNING: - terminal.tprint(msg, colour=color, col=_color, stderr=True) + terminal.tprint(msg, newline=newline, colour=color, col=_color, + stderr=True) else: - terminal.tprint(msg, colour=color, col=_color) + terminal.tprint(msg, newline=newline, colour=color, col=_color) if level == FATAL: sys.exit(1) -def do_output(level, msg): +def do_output(level, msg, newline=True): """Output a message to the terminal. Args: level: Verbosity level for this message. It will only be displayed if this as high as the currently selected level. - msg; Message to display. + msg: Message to display. + newline: True to add a newline at the end. """ - _output(level, msg) + _output(level, msg, newline=newline) def fatal(msg): """Display an error message and exit Args: - msg; Message to display. + msg: Message to display. """ _output(FATAL, msg, _color.RED) -def error(msg): +def error(msg, newline=True): """Display an error message Args: - msg; Message to display. + msg: Message to display. + newline: True to add a newline at the end. """ - _output(ERROR, msg, _color.RED) + _output(ERROR, msg, _color.RED, newline=newline) -def warning(msg): +def warning(msg, newline=True): """Display a warning message Args: - msg; Message to display. + msg: Message to display. + newline: True to add a newline at the end. """ - _output(WARNING, msg, _color.YELLOW) + _output(WARNING, msg, _color.YELLOW, newline=newline) -def notice(msg): +def notice(msg, newline=True): """Display an important infomation message Args: - msg; Message to display. + msg: Message to display. + newline: True to add a newline at the end. """ - _output(NOTICE, msg) + _output(NOTICE, msg, newline=newline) -def info(msg): +def info(msg, newline=True): """Display an infomation message Args: - msg; Message to display. + msg: Message to display. + newline: True to add a newline at the end. """ - _output(INFO, msg) + _output(INFO, msg, newline=newline) -def detail(msg): +def detail(msg, newline=True): """Display a detailed message Args: - msg; Message to display. + msg: Message to display. + newline: True to add a newline at the end. """ - _output(DETAIL, msg) + _output(DETAIL, msg, newline=newline) -def debug(msg): +def debug(msg, newline=True): """Display a debug message Args: - msg; Message to display. + msg: Message to display. + newline: True to add a newline at the end. """ - _output(DEBUG, msg) + _output(DEBUG, msg, newline=newline) -def user_output(msg): +def user_output(msg, newline=True): """Display a message regardless of the current output level. This is used when the output was specifically requested by the user. Args: - msg; Message to display. + msg: Message to display. + newline: True to add a newline at the end. """ - _output(ERROR, msg) + _output(ERROR, msg, newline=newline) def init(_verbose=WARNING, stdout=sys.stdout, allow_colour=True): """Initialize a new output object.