def _serialize_inventory(inventory, generation=None):
 data = {field: getattr(inventory, field) for field in OUTPUT_INVENTORY_FIELDS}
 if generation:
  data['resource_provider_generation'] = generation
 return data

def _serialize_inventory ( inventory , generation = None ) : data = { field : getattr ( inventory , field ) for field in OUTPUT_INVENTORY_FIELDS } if generation : data [ 'resource_provider_generation' ] = generation return data
turn a single inventory into a dictionary .