- (_, lvm_name, convert_fn) = fields_def[field_to_idx[field_name]]
-
- value = raw_data[lvm_name_to_idx[lvm_name]]
-
- if convert_fn:
- value = convert_fn(value)
-
- row.append(value)
+ (_, lvm_names, mapper) = fields_def[field_to_idx[field_name]]
+
+ values = [raw_data[lvm_name_to_idx[i]] for i in lvm_names]
+
+ if callable(mapper):
+ # we got a function, call it with all the declared fields
+ val = mapper(*values) # pylint: disable=W0142
+ elif len(values) == 1:
+ assert mapper is None, ("Invalid mapper value (neither callable"
+ " nor None) for one-element fields")
+ # we don't have a function, but we had a single field
+ # declared, pass it unchanged
+ val = values[0]
+ else:
+ # let's make sure there are no fields declared (cannot map >
+ # 1 field without a function)
+ assert not values, "LVM storage has multi-fields without a function"
+ val = mapper
+
+ row.append(val)