def test_zipapply(): funcs = (add_one, add_one, times_two) values = (1, 2, 3) result = zipapply(funcs, values) assert result == [2, 3, 6] result = zipapply([], []) assert result == []
def get_dest_columns(self, cursor): mapping_loaders = map(FunctionMapping.load, self.mapping_signature) mappings = zipapply(mapping_loaders, repeat(cursor, len(mapping_loaders))) mapping_columns = [m.dest_column for m in mappings] return self.transforming_columns() + mapping_columns
def create_copy_from_line(data_types, row): """Return line compatible with COPY FROM command.""" entity_id, timestamp, attributes = row value_mappers = map(value_mapper_by_type.get, data_types) values = chain( (str(entity_id), str(timestamp)), zipapply(value_mappers, attributes) ) return "\t".join(values) + "\n"