buildman: Extract tag parsing from parse() into _parse_tag()
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 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
@@ -1114,6 +1114,22 @@ class ExtendedParser:
|
||||
f'{fname}:{linenum}: Invalid target regex')
|
||||
self.targets.append(['regex', line.strip()])
|
||||
else:
|
||||
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')
|
||||
@@ -1132,6 +1148,3 @@ class ExtendedParser:
|
||||
self.in_targets = True
|
||||
else:
|
||||
raise ValueError(f"{fname}:{linenum}: Unknown tag '{tag}'")
|
||||
|
||||
self.finish()
|
||||
return self.extended
|
||||
|
||||
Reference in New Issue
Block a user