From patchwork Sun Feb 22 15:42:50 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1931 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=1771775058; bh=ImQimOLM7y/PZbyTUjNae/XX0OH52fvhC4NeUcTXiTY=; 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=OBMn42XBOMqmMa2fF9SKxbuAqRl+l1AJrh1tXE4xRLHNMMZA4SVKneiU3pmhEA6nw ufK+Ch4CX3OOp9dQTrUqqkUcpNXIGLjSXFaAIKvbAjitYUgQTnjc67FS98OIa/79PT G3G1WvwBuhPjlFGxCRSveVTGnFZXR0wJuMvJy2d86tildTztFYrE6vUQWSIIrTSQaF trWjF4U3bppcnjTuvz8Rr5DA80qe67VDLLDcSje9Cq6O9CQr6miZlnWHHBRRHkrzwM tfFZLEoaduVrAG6sdWLZOnsW5C0t3vluU5ahR4Lt4aARiT7ZTFYyWzIuavfeAkLQP4 td08bpO9RDU9w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6128769D53 for ; Sun, 22 Feb 2026 08:44:18 -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 En0MC7G9KvQS for ; Sun, 22 Feb 2026 08:44:18 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771775058; bh=ImQimOLM7y/PZbyTUjNae/XX0OH52fvhC4NeUcTXiTY=; 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=OBMn42XBOMqmMa2fF9SKxbuAqRl+l1AJrh1tXE4xRLHNMMZA4SVKneiU3pmhEA6nw ufK+Ch4CX3OOp9dQTrUqqkUcpNXIGLjSXFaAIKvbAjitYUgQTnjc67FS98OIa/79PT G3G1WvwBuhPjlFGxCRSveVTGnFZXR0wJuMvJy2d86tildTztFYrE6vUQWSIIrTSQaF trWjF4U3bppcnjTuvz8Rr5DA80qe67VDLLDcSje9Cq6O9CQr6miZlnWHHBRRHkrzwM tfFZLEoaduVrAG6sdWLZOnsW5C0t3vluU5ahR4Lt4aARiT7ZTFYyWzIuavfeAkLQP4 td08bpO9RDU9w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 46F5669C5E for ; Sun, 22 Feb 2026 08:44:18 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771775056; bh=A0mxhAzSDvq3cLc7jFKnFLyMuOY2jQVqJ3pSl3yc3DA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tkh8a0xodhQnDnsurbThkZugGsWy+g18NNExj4m+G8d4FiUOK7W0IIQJs1w2/FUD6 otsYhxWUG4DHHqHSueF/ul86sJzMtUKI00e91Yk3B7g5cNTnRF1Ifu3lhrZWA4NqoO pqNe2HGTTs9+nopIZ99HpmcwR2BMJKrjMlvEn4q+WNLrnU0xvN0DzrNvjNSS239DLw PNBWaoLoUo6/LfVMam1Dy0xFGkRnuIyf1z5kHkiF3fGK4+Ja4tGM0FvUUX1oENeBp4 92EaNY2Lpw556rdL9B4DVvI6vjHdjKTzd8q+ETCn5Ug+3lUexLL7UQW5DvITNykTW/ DXFDhdsZlFiaA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 158EC69D58; Sun, 22 Feb 2026 08:44:16 -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 SOd2KDKubLXO; Sun, 22 Feb 2026 08:44:15 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771775051; bh=R4jDeGia1v1L5rwkZXzSsXI2yJDoWp5Di7HBAWnxQ6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MujNQWVEqjA0a84JWrV3GumYHGF1wEMO5CzlnzUM1Boer9aKFYDrbPOoRfpb6Fik9 OlIgIuk5r+LvcOeo3zXqg23QIokAnR8z9dMTd+kdDNmiKn5MqebK0Xlbp+b5qDXuLt Y7KbEJFnGrJF2a72Bqbm5XNwj76LOocCG1zGrEeQGhz3d22pBbp8A1++I6vBJYYdFF G2yonqbBH7q8D58Rhvi7RP9nkKWsoRo2rF6MjZrTK6jN7cyRF/kawj+uj056RTOrjd MtfwU5eivS5hsfx0E2Zdg/nmLsVwEfdqiivEsyttIrzz8vpo7jJUU4wnpAWbEhh2DZ x1POioljn/43Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6644869C5C; Sun, 22 Feb 2026 08:44:11 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 22 Feb 2026 08:42:50 -0700 Message-ID: <20260222154303.2851319-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260222154303.2851319-1-sjg@u-boot.org> References: <20260222154303.2851319-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: J3VMXNJMF2OQHLR4EA3PZX3TC7OFMASQ X-Message-ID-Hash: J3VMXNJMF2OQHLR4EA3PZX3TC7OFMASQ 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: Simon Glass , "Claude Opus 4 . 6" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 10/16] pickman: Use tools for file I/O 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 Replace manual open() calls with tools.read_file() and tools.write_file() for consistency with the rest of the codebase. Co-developed-by: Claude Opus 4.6 Signed-off-by: Simon Glass --- tools/pickman/agent.py | 5 +++-- tools/pickman/control.py | 13 +++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tools/pickman/agent.py b/tools/pickman/agent.py index 63952c1c005..4b914e314e8 100644 --- a/tools/pickman/agent.py +++ b/tools/pickman/agent.py @@ -14,6 +14,7 @@ our_path = os.path.dirname(os.path.realpath(__file__)) sys.path.insert(0, os.path.join(our_path, '..')) # pylint: disable=wrong-import-position,import-error +from u_boot_pylib import tools from u_boot_pylib import tout # Signal file for agent to communicate status back to pickman @@ -278,8 +279,8 @@ def read_signal_file(repo_path=None): return None, None try: - with open(signal_path, 'r', encoding='utf-8') as fhandle: - lines = fhandle.read().strip().split('\n') + data = tools.read_file(signal_path, binary=False) + lines = data.strip().split('\n') status = lines[0] if lines else None last_commit = lines[1] if len(lines) > 1 else None diff --git a/tools/pickman/control.py b/tools/pickman/control.py index 48f7ced1617..057e4400adb 100644 --- a/tools/pickman/control.py +++ b/tools/pickman/control.py @@ -26,6 +26,7 @@ from pickman import ftest from pickman import gitlab_api from u_boot_pylib import command from u_boot_pylib import terminal +from u_boot_pylib import tools from u_boot_pylib import tout # Default database filename @@ -1458,8 +1459,7 @@ def get_history(fname, source, commits, branch_name, conv_log): # Read existing content existing = '' if os.path.exists(fname): - with open(fname, 'r', encoding='utf-8') as fhandle: - existing = fhandle.read() + existing = tools.read_file(fname, binary=False) # Remove existing entry for this branch (from ## header to ---) pattern = rf'## [^\n]+\n\nBranch: {re.escape(branch_name)}\n.*?---\n\n' existing = re.sub(pattern, '', existing, flags=re.DOTALL) @@ -1467,8 +1467,7 @@ def get_history(fname, source, commits, branch_name, conv_log): content = existing + entry # Write updated history file - with open(fname, 'w', encoding='utf-8') as fhandle: - fhandle.write(content) + tools.write_file(fname, content, binary=False) # Generate commit message commit_msg = (f'pickman: Record cherry-pick of {len(commits)} commits ' @@ -2429,11 +2428,9 @@ Comments addressed: # Append to history file existing = '' if os.path.exists(HISTORY_FILE): - with open(HISTORY_FILE, 'r', encoding='utf-8') as fhandle: - existing = fhandle.read() + existing = tools.read_file(HISTORY_FILE, binary=False) - with open(HISTORY_FILE, 'w', encoding='utf-8') as fhandle: - fhandle.write(existing + entry) + tools.write_file(HISTORY_FILE, existing + entry, binary=False) # Commit the history file run_git(['add', '-f', HISTORY_FILE])