Introduce helper `get_column_name()`

This commit is contained in:
Matthieu Gautier 2024-03-25 15:17:10 +01:00
parent 6501464f76
commit 696242a0b1
1 changed files with 6 additions and 2 deletions

View File

@ -135,7 +135,7 @@ def select_build_targets(criteria):
raise ValueError("No definition match with current context.") raise ValueError("No definition match with current context.")
def get_platform_name(): def get_column_value(column_name):
from common import COMPILE_CONFIG, OS_NAME from common import COMPILE_CONFIG, OS_NAME
context = Context(COMPILE_CONFIG=COMPILE_CONFIG, OS_NAME=OS_NAME) context = Context(COMPILE_CONFIG=COMPILE_CONFIG, OS_NAME=OS_NAME)
@ -143,7 +143,11 @@ def get_platform_name():
reader = csv.DictReader(strip_array(BUILD_DEF), dialect=TableDialect()) reader = csv.DictReader(strip_array(BUILD_DEF), dialect=TableDialect())
for row in reader: for row in reader:
if context.match(row): if context.match(row):
name = row["platform_name"] name = row[column_name]
return name or None return name or None
raise ValueError("No definition match with current context.") raise ValueError("No definition match with current context.")
def get_platform_name():
return get_column_value("platform_name")