def transform_geography_targeting_to_dfp(targeting):
    included_locations = []
    excluded_locations = []

    includes, excludes = targeting.get_includes_and_excludes()

    for i in includes:
        if isinstance(i, Geography):
            included_locations.append(_geo_to_dfp(i))

    for e in excludes:
        if isinstance(e, Geography):
            excluded_locations.append(_geo_to_dfp(e))

    target_dict = {}
    if included_locations:
        target_dict['targetedLocations'] = included_locations

    if excluded_locations:
        target_dict['excludedLocations'] = excluded_locations

    return target_dict
Convert geography targeting model to dfp dictionary
dataset/ETHPy150Open chartbeat-labs/parselmouth/parselmouth/adapters/dfp/targeting_utils.py/transform_geography_targeting_to_dfp