

def transform_technology_targeting_from_dfp(targeting):
    '\n    Convert DFP technology targeting data to TargetingCriterion\n\n    @param targeting: dict\n    @return: TargetingCriterion\n    '
    if (not targeting):
        return None
    target_data = {
        'include': [],
        'exclude': [],
    }
    for (tech_type, _map) in TECHNOLOGY_KEY_MAP.items():
        target = targeting.get(_map['target_name'])
        if (not target):
            continue
        _map_type = _map['type']
        if (_map_type == 'list'):
            _list_name = _map['list_name']
            browser_list = []
            for item in target[_list_name]:
                tech_target = Technology(id=item['id'], name=item.get('name'), type=tech_type)
                browser_list.append(tech_target)
            if target['isTargeted']:
                target_data['include'] += browser_list
            else:
                target_data['exclude'] += browser_list
        elif (_map_type == 'categorical'):
            for _cat_key in ['include', 'exclude']:
                dfp_key = _map[_cat_key]
                raw_data = target.get(dfp_key, [])
                for item in raw_data:
                    tech_target = Technology(id=item['id'], name=item.get('name'), type=tech_type)
                    target_data[_cat_key].append(tech_target)
    includes = target_data['include']
    inc = TargetingCriterion(includes, TargetingCriterion.OPERATOR.OR)
    excludes = target_data['exclude']
    exl = TargetingCriterion(excludes, TargetingCriterion.OPERATOR.OR)
    if (includes and excludes):
        return (inc & (~ exl))
    elif raw_data:
        return inc
    elif excludes:
        return (~ exl)
    else:
        return None

dataset/ETHPy150Open chartbeat-labs/parselmouth/parselmouth/adapters/dfp/targeting_utils.py transform_technology_targeting_from_dfp/VarMisuse@326/545 `includes`->`raw_data`