def transform_project_data(item):
    name = clean_string(item.get("project_title"), default=None)
    return {
        "name": name,
        "slug": slugify(name, allow_unicode=True),
        "start_year": parse_int(item.get("project_start_year")),
        "start_month": parse_int(item.get("project_start_month")),
        "start_day": parse_int(item.get("project_start_day")),
        "status": project_status_from_statuses(item.get("project_status")),
        "sources": make_url_list(item.get("sources")),
        "notes": clean_string(item.get("notes")),
        "commencement_year": parse_int(item.get("commencement_year")),
        "commencement_month": parse_int(item.get("commencement_month")),
        "commencement_day": parse_int(item.get("commencement_day")),
        "total_cost": parse_int(item.get("total_project_cost")),
        "total_cost_currency": item.get("total_project_cost_currency"),
        "planned_completion_year": parse_int(item.get("planned_year_of_completion")),
        "planned_completion_month": parse_int(item.get("planned_month_of_completion")),
        "planned_completion_day": parse_int(item.get("planned_day_of_completion")),
        "new": evaluate_project_new_value(item.get("new")),
        "infrastructure_type": infrastructure_type_object(item.get('infrastructure_type')),
        "initiative": initiative_object(item.get('program_initiative')),
        "collection_stage": collection_stage_from_value(item.get('collection_stage')),
        "verified_path": coerce_to_boolean_or_null(item.get('verified_path'))
    }
Example #2
0
def transform_project_data(item):
    name = clean_string(item.get("project_title"), default=None)
    return {
        "name":
        name,
        "slug":
        slugify(name, allow_unicode=True),
        "start_year":
        parse_int(item.get("project_start_year")),
        "start_month":
        parse_int(item.get("project_start_month")),
        "start_day":
        parse_int(item.get("project_start_day")),
        "status":
        project_status_from_statuses(item.get("project_status")),
        "sources":
        make_url_list(item.get("sources")),
        "notes":
        clean_string(item.get("notes")),
        "commencement_year":
        parse_int(item.get("commencement_year")),
        "commencement_month":
        parse_int(item.get("commencement_month")),
        "commencement_day":
        parse_int(item.get("commencement_day")),
        "total_cost":
        parse_int(item.get("total_project_cost")),
        "total_cost_currency":
        item.get("total_project_cost_currency"),
        "planned_completion_year":
        parse_int(item.get("planned_year_of_completion")),
        "planned_completion_month":
        parse_int(item.get("planned_month_of_completion")),
        "planned_completion_day":
        parse_int(item.get("planned_day_of_completion")),
        "new":
        evaluate_project_new_value(item.get("new")),
        "infrastructure_type":
        infrastructure_type_object(item.get('infrastructure_type')),
        "initiative":
        initiative_object(item.get('program_initiative')),
        "collection_stage":
        collection_stage_from_value(item.get('collection_stage')),
        "verified_path":
        coerce_to_boolean_or_null(item.get('verified_path'))
    }
Example #3
0
def evaluate_project_new_value(list_val):
    key = 'new_name'
    raw_value = first_value_or_none(list_val)
    if isinstance(raw_value, dict) and key in raw_value:
        return coerce_to_boolean_or_null(raw_value[key])
    return None
def evaluate_project_new_value(list_val):
    key = 'new_name'
    raw_value = first_value_or_none(list_val)
    if isinstance(raw_value, dict) and key in raw_value:
        return coerce_to_boolean_or_null(raw_value[key])
    return None