Пример #1
0
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
Пример #2
0
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
Пример #3
0
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
Пример #4
0
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