def map_access_right(ar: str) -> str: match ar: case 'open': return 'Open Access' case 'closed': return 'Closed' case 'embargo': return 'Embargo' case 'restricted': return 'Restricted' case _: return '' def trasform_product(p: dict) -> dict: p['accessRights'] = list( filter(lambda ar: ar != '', map(lambda m: map_access_right(m.get('access_right')), p.get('manifestations')))) return p transform_entities = { # 'products': trasform_product }