Skip to content

Commit e12e377

Browse files
de-nordiccarlescufi
authored andcommitted
scripts: runners: Modify BuildConfiguration._parse to iterate over file
The method has been changed to iterate directly over file instead of preloading it. Signed-off-by: Dominik Ermel <[email protected]>
1 parent 0dfd191 commit e12e377

File tree

1 file changed

+20
-22
lines changed
  • scripts/west_commands/runners

1 file changed

+20
-22
lines changed

scripts/west_commands/runners/core.py

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -149,28 +149,26 @@ def _parse(self, filename: str):
149149
not_set = re.compile('^# (?P<option>CONFIG_[A-Za-z0-9_]+) is not set$')
150150

151151
with open(filename, 'r') as f:
152-
lines = f.readlines()
153-
154-
for line in lines:
155-
match = opt_value.match(line)
156-
if match:
157-
value = match.group('value').rstrip()
158-
if value.startswith('"') and value.endswith('"'):
159-
value = value[1:-1]
160-
else:
161-
try:
162-
base = 16 if value.startswith('0x') else 10
163-
self.options[match.group('option')] = int(value, base=base)
164-
continue
165-
except ValueError:
166-
pass
167-
168-
self.options[match.group('option')] = value
169-
continue
170-
171-
match = not_set.match(line)
172-
if match:
173-
self.options[match.group('option')] = 'n'
152+
for line in f:
153+
match = opt_value.match(line)
154+
if match:
155+
value = match.group('value').rstrip()
156+
if value.startswith('"') and value.endswith('"'):
157+
value = value[1:-1]
158+
else:
159+
try:
160+
base = 16 if value.startswith('0x') else 10
161+
self.options[match.group('option')] = int(value, base=base)
162+
continue
163+
except ValueError:
164+
pass
165+
166+
self.options[match.group('option')] = value
167+
continue
168+
169+
match = not_set.match(line)
170+
if match:
171+
self.options[match.group('option')] = 'n'
174172

175173
class MissingProgram(FileNotFoundError):
176174
'''FileNotFoundError subclass for missing program dependencies.

0 commit comments

Comments
 (0)