From patchwork Sat Jan 3 01:18:38 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1196 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=1767403172; bh=RNKnamaOLVob8f19PiSsCsWWj9aS/dptgHtM7Tu5zjg=; 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=F0dN+LypwZx8doDEYY+I2xmTcQj4cXitiP4lCRrAK3tPtz/yRkO4TO+63Q66GhoXZ +2TnhxpUGPrzzYgOJPd267MAbS2Xy6gsebtBm/LSjHRgP0Fr0U+AkDw5OiNGNcbfiy FBjacb5KmV+Y+fnwOYbPo3ma4EImFmc/8n/P+WZxPt1jFmracZ6bVjSpgQ/ghEt51O TQQ9/QUMoBzTwhpOU0DWhxGBQRVzdkEeNDCmMrohsTckOcOMKExRhOR38bXs1P4WWD +ejv8sLEsoevLKH3fVs/gVaSUtOrsLHDIyi9WG6F7lBlx4dpYFYc68Wjpy8Ba3Lx6k 5nvN7ckdv3Nzg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EFC306904E for ; Fri, 2 Jan 2026 18:19:32 -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 eDzzTwLvyKkv for ; Fri, 2 Jan 2026 18:19:32 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767403172; bh=RNKnamaOLVob8f19PiSsCsWWj9aS/dptgHtM7Tu5zjg=; 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=F0dN+LypwZx8doDEYY+I2xmTcQj4cXitiP4lCRrAK3tPtz/yRkO4TO+63Q66GhoXZ +2TnhxpUGPrzzYgOJPd267MAbS2Xy6gsebtBm/LSjHRgP0Fr0U+AkDw5OiNGNcbfiy FBjacb5KmV+Y+fnwOYbPo3ma4EImFmc/8n/P+WZxPt1jFmracZ6bVjSpgQ/ghEt51O TQQ9/QUMoBzTwhpOU0DWhxGBQRVzdkEeNDCmMrohsTckOcOMKExRhOR38bXs1P4WWD +ejv8sLEsoevLKH3fVs/gVaSUtOrsLHDIyi9WG6F7lBlx4dpYFYc68Wjpy8Ba3Lx6k 5nvN7ckdv3Nzg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DEA1668FAF for ; Fri, 2 Jan 2026 18:19:32 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767403170; bh=BEcC/7BuJTrH7BlRB74VVh0eHKTPbI1oD7aZHdOylI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LxKZ9FfhxSu07XWen3hKbK1zzS4vht43CBXVqiwEGSvX875b9gGXo0/aPo/M0LoVz GEBzS50bKpyDcHWZX0UVP1H+P5LlyVpAUw7oMgl/KpVCVBqZmbCkpgrn8OkJxLug15 I9SZZ5d3vOrQRgBENDEF1HrYZwvBWiThVa8hWcezp7/BrVXMD0kdnuMJxhDnZVbDgT rvMh77/OnvoGrBVVqTAV8d+yligBmyL9mnV97GOkrFQmLs8HBrd3W0ojfbYt6Geh1P qLMHEIjCRDKLm+LFppH84pR+2oyeD4x0m+YXx+cGuNuMWbPMeogTrFbBdU1tRePnBT wr9PUX4JbsXDA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D8B1168FAF; Fri, 2 Jan 2026 18:19:30 -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 CS1bFuExGxnB; Fri, 2 Jan 2026 18:19:30 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767403166; bh=/WelOTMq2+fi9WvFIcmtbZIOE7TJo0NxCfLbaFA/qMo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LFtaR7W9hzBRMf9SAhvyidWsKVLwr7MaSsdC5X0rV/R52ILJewSiSmmte70Pzoo2Z kCZmw+/SNgXMNtOBuuFkrfTzdCU7KxUXzwNUS0vp8SQLYZYDfRmQY631t7Hl+zYdug PBuKkUPTaKaBYuW9hxQWRQK92ji1sv1Fgt66sjVKL/yFGnXBkLbs+HhPcifF/oAkR2 QmBqGPw1NZAxLfXfkyvy+pzZWKiwYzy742ZAQPX8Ku8If30G4rOU91najcanyz5MDB YbvNS8pzRzySm+Tneecr6EgSTM9s2RPZ1plG3jh4lOK1VLxAscoYcAiqqM4gknAbdk vGG8FXjaWaiBA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id AB29568F5F; Fri, 2 Jan 2026 18:19:26 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 2 Jan 2026 18:18:38 -0700 Message-ID: <20260103011908.149445-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260103011908.149445-1-sjg@u-boot.org> References: <20260103011908.149445-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: WX3WGZIHEBAAGB6ROZ2MYHMGDUSWMQYP X-Message-ID-Hash: WX3WGZIHEBAAGB6ROZ2MYHMGDUSWMQYP 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 02/24] 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 --- 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.