

def clean_target_dict(data):
    "\n    There are many unimplemented fields throughout parselmouth,\n    for example some types of targeting are not yet implemented.\n    In these cases, we must clean the dictionary before we pass\n    it back to DFP. Fields like X.Type exist in many places, and these\n    must be replaced with 'xsi_type' for exaample. Also, unneeded fields\n    sometimes raise errors when passed back to DFP.\n\n    @param data: dict\n    @return: dict\n    "
    if (not isinstance(data, dict)):
        return data
    at_bottom = True
    cln_dict = {
        
    }
    for (_key, _val) in data.items():
        if isinstance(_val, dict):
            at_bottom = False
            cln_dict[_key] = clean_target_dict(_val)
        elif isinstance(_val, list):
            at_bottom = False
            cln_dict[_key] = [clean_target_dict(d) for d in _val]
        elif (_key.find('_Type') >= 0):
            cln_dict['xsi_type'] = _val
        else:
            cln_dict[_key] = _val
    if at_bottom:
        clean_dict = {
            
        }
        for (_key, _val) in cln_dict.items():
            if ((_key.find('id') >= 0) or (_key.find('Id') >= 0)):
                clean_dict[_key] = data
            elif (_key == 'xsi_type'):
                clean_dict[_key] = _val
    else:
        clean_dict = cln_dict
    return clean_dict

dataset/ETHPy150Open chartbeat-labs/parselmouth/parselmouth/adapters/dfp/targeting_utils.py clean_target_dict/VarMisuse@205/447 `_val`->`data`