

def transform_inventory_targeting_from_dfp(targeting):
    '\n    Convert dfp dictionary to inventory targeting model\n\n    @param targeting: dict\n    @return: TargetingCriterion\n    '
    if (not targeting):
        return None
    include_list = []
    placement_ids = targeting.get('targetedPlacementIds', [])
    for pl_id in placement_ids:
        place = Placement(id=pl_id)
        include_list.append(place)
    ad_units = targeting.get('targetedAdUnits', [])
    for au in ad_units:
        include_list.append(_adunit_from_dfp(au))
    exclude_list = []
    ad_units = targeting.get('excludedAdUnits', [])
    for au in ad_units:
        exclude_list.append(_adunit_from_dfp(au))
    return _make_criterion_from_lists(include_list, exclude_list)

dataset/ETHPy150Open chartbeat-labs/parselmouth/parselmouth/adapters/dfp/targeting_utils.py transform_inventory_targeting_from_dfp/original