Create a schema that clones the given schema, but containing the given list of values.
(schema, values, throw_on_type_mismatch=False)
| 1106 | |
| 1107 | |
| 1108 | def from_blob_list(schema, values, throw_on_type_mismatch=False): |
| 1109 | """ |
| 1110 | Create a schema that clones the given schema, but containing the given |
| 1111 | list of values. |
| 1112 | """ |
| 1113 | assert isinstance(schema, Field), 'Argument `schema` must be a Field.' |
| 1114 | if isinstance(values, BlobReference): |
| 1115 | values = [values] |
| 1116 | record = schema.clone_schema() |
| 1117 | scalars = record.all_scalars() |
| 1118 | assert len(scalars) == len(values), ( |
| 1119 | 'Values must have %d elements, got %d.' % (len(scalars), len(values)) |
| 1120 | ) |
| 1121 | for scalar, value in zip(scalars, values): |
| 1122 | scalar.set_value(value, throw_on_type_mismatch, unsafe=True) |
| 1123 | return record |
| 1124 | |
| 1125 | |
| 1126 | def as_record(value): |
searching dependent graphs…