def parsed_as_values(string_table): values = [] column_names = string_table['column_names'] for row in string_table['rows']: cell = row[column_names[0]] v = parse(cell) assert v is not None, f"Failed to parse `{cell}'" values.append(v) string_table['values'] = values
def _parse_value(cell: str, variables: dict) -> Value: m = pattern.match(cell) if m: var = m.group(1) assert var in variables, f"Invalid expect variable usages: {cell}" cell = variables.get(var, None) assert cell is not None value = parse(cell) assert value is not None, f"parse error: column is {cell}" return value
def dataset(string_table): ds = DataSet() ds.column_names = string_table['column_names'] ds.rows = [] for row in string_table['rows']: nrow = Row() nrow.values = [] for column in ds.column_names: value = parse(row[column]) assert value is not None, \ f'parse error: column is {column}:{row[column]}' nrow.values.append(value) ds.rows.append(nrow) return ds
def parsed_as_values(string_table): cell = string_table['text'] v = parse(cell) assert v is not None, f"Failed to parse `{cell}'" string_table['value'] = v