From patchwork Sat Jan 3 20:32:31 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1252 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=1767472399; bh=nQdCSdiWX4kFuIauHlhV9DlkHc6xK3vV0neqv2ZpVBE=; 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=wZVu/DKCvagfoQdpYPTs4HFe90TRYekoa2UZQB0anGqesaUtteguwhNNtiOV4ebU+ i4yrAjOkne4gWvml8V6/uOs1WG4dAkRi2eMyQHqVpqICG6nh7u4WCiWwpqC512aNDW /wzJhoCzPcsh7XVHQ7nGY2qrzHOoggQ9rucudohtnl3Yq4g9r4DT2BRoAiE0fMrDnp ps2l06n/h1UAWRsAXtC+fw6yNEWMKzAAUo0vJ+NFO1UYj3nGmrhXoKkK2mgwon+0I+ m9TERtuhBy/9Kx7de8vQyPJ0uUFfLjSaM+0cy8HFjZJvA4Ukcj8a6A/zRioAZ0zw2U meXBJaiGyan/A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B6FE2690BF for ; Sat, 3 Jan 2026 13:33:19 -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 aLIGlQvz12n9 for ; Sat, 3 Jan 2026 13:33:19 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767472399; bh=nQdCSdiWX4kFuIauHlhV9DlkHc6xK3vV0neqv2ZpVBE=; 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=wZVu/DKCvagfoQdpYPTs4HFe90TRYekoa2UZQB0anGqesaUtteguwhNNtiOV4ebU+ i4yrAjOkne4gWvml8V6/uOs1WG4dAkRi2eMyQHqVpqICG6nh7u4WCiWwpqC512aNDW /wzJhoCzPcsh7XVHQ7nGY2qrzHOoggQ9rucudohtnl3Yq4g9r4DT2BRoAiE0fMrDnp ps2l06n/h1UAWRsAXtC+fw6yNEWMKzAAUo0vJ+NFO1UYj3nGmrhXoKkK2mgwon+0I+ m9TERtuhBy/9Kx7de8vQyPJ0uUFfLjSaM+0cy8HFjZJvA4Ukcj8a6A/zRioAZ0zw2U meXBJaiGyan/A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A2AD3690BC for ; Sat, 3 Jan 2026 13:33:19 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767472398; bh=MV8LO7jGsPjTt8UOeyihJuP0Sv2Jrp98MaUoyDKMkYY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rm9CpFnNvrf41f+cQLZTXw5UPR5cyFbpwXHvWaBjOjYDgW9t3ZTrSccVSPt+UPMGq lsh1hJuDLwp/uMP21kWQaS91t2afzGIJQ5+WP+zTI8B31SFLqJQ/4oyISLXDKwyQJf ZHF+8Nm+OOrJVDcv6yooPd0MxwtC36ebRuLpWGJaAliByfKCOfL8Shhon6nwaKLde6 6uA4HYTcliDZam4eL+mGpz6xoPVE03TdUV/+fz02CmdTiWXeHeEb6hDxfq+VgJqdGp 5/rygyxX5JjVZHpASyrM5h5SCZhHM0LCEGEKc9SAs8nnB7StAkDptXBN72DATAQZ5j 3nKWnH/BW+PJA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 832E968F35; Sat, 3 Jan 2026 13:33: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 10026) with ESMTP id 6wWn73TmmEPG; Sat, 3 Jan 2026 13:33:18 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767472394; bh=YGmPP3I4XnrSl4oqC87i7dnWX6eixY6sDMTnK7rpdaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TwrlvcqoqoM/yXoGLOTLSxYe6RQnLhYTyQBVmtftSZkhbVW05hUK0PCztbPrbvD3U urpjO7SxjnqBGnTnIk3BFUhvQ6v1Dj3vSX4CfGg8QN0oJ/TqV+8/ZpV4ZjYRNEU/9/ gelQm9inXuGZTzwUEWc0icwBCAWB2XOZJy6vtkGSNUCmYRePK+S+Itbw0zYAQ5cVxO gg7EHgwnSyjSKZDQfznRpcZuN/+DwTfa/ZLpCM+LDVhGg6aKJo2BcUcfvQICUuhGkd ufrqxjFH58ncwWqyPOS83cB42Vg3eCsIPKjnTFvxM0wBzlJEnDFIHVnI3o3E7HXfhX jz9azuS+G+8rw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 188B868FC8; Sat, 3 Jan 2026 13:33:14 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 3 Jan 2026 13:32:31 -0700 Message-ID: <20260103203243.3727493-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260103203243.3727493-1-sjg@u-boot.org> References: <20260103203243.3727493-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: JR7BV4R7TG4CL4CJ2RBMRCG55LGS5PRN X-Message-ID-Hash: JR7BV4R7TG4CL4CJ2RBMRCG55LGS5PRN 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 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/12] buildman: Extract tag parsing from parse() into _parse_tag() 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 Move the handling of tag lines (name:, desc:, fragment:, targets:) into a separate method to reduce complexity of parse() Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- tools/buildman/boards.py | 49 +++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/tools/buildman/boards.py b/tools/buildman/boards.py index 3b132691435..1983e4a50d6 100644 --- a/tools/buildman/boards.py +++ b/tools/buildman/boards.py @@ -1114,24 +1114,37 @@ class ExtendedParser: f'{fname}:{linenum}: Invalid target regex') self.targets.append(['regex', line.strip()]) else: - pair = line.split(':') - if len(pair) != 2: - raise ValueError(f'{fname}:{linenum}: Invalid tag') - tag, rest = pair - value = rest.strip() - if tag == 'name': - self.finish() - if ' ' in value: - raise ValueError(f'{fname}:{linenum}: Invalid name') - self.name = value - elif tag == 'desc': - self.desc = value - elif tag == 'fragment': - self.fragments.append(value) - elif tag == 'targets': - self.in_targets = True - else: - raise ValueError(f"{fname}:{linenum}: Unknown tag '{tag}'") + self._parse_tag(fname, linenum, line) self.finish() return self.extended + + def _parse_tag(self, fname, linenum, line): + """Parse a tag line (one not starting with a space) + + Args: + fname (str): Filename (for error messages) + linenum (int): Line number (for error messages) + line (str): Line to parse + + Raises: + ValueError: Invalid syntax + """ + pair = line.split(':') + if len(pair) != 2: + raise ValueError(f'{fname}:{linenum}: Invalid tag') + tag, rest = pair + value = rest.strip() + if tag == 'name': + self.finish() + if ' ' in value: + raise ValueError(f'{fname}:{linenum}: Invalid name') + self.name = value + elif tag == 'desc': + self.desc = value + elif tag == 'fragment': + self.fragments.append(value) + elif tag == 'targets': + self.in_targets = True + else: + raise ValueError(f"{fname}:{linenum}: Unknown tag '{tag}'")