Skip to content

Commit dfa28ba

Browse files
authored
Refactor car parsing logic in generate.py to handle new "PlatformConfig"
1 parent 1b95cf7 commit dfa28ba

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

generate.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,19 @@ class CAR:
4848
cars = []
4949

5050
for path in paths:
51+
logging.info("Parsing %s", path)
5152
with open(path, "r") as f:
5253
tree = ast.parse(f.read())
5354
for node in ast.walk(tree):
5455
if isinstance(node, ast.ClassDef) and node.name == "CAR":
5556
for c in node.body:
5657
if isinstance(c, ast.Assign):
57-
cars.append(c.value.s)
58+
if isinstance(c.value, ast.Str):
59+
cars.append(c.value.s)
60+
# Sometimes it's an object initializer,
61+
# If so, use the first argument
62+
elif isinstance(c.value, ast.Call):
63+
cars.append(c.value.args[0].s)
5864

5965
# Log the cars
6066
logging.info("Found %d cars in %s", len(cars), branch)

0 commit comments

Comments
 (0)