refactor: formatting
This commit is contained in:
		@@ -8,12 +8,14 @@ HEADERS = {
 | 
				
			|||||||
    "Content-Type": "application/json"
 | 
					    "Content-Type": "application/json"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def load_osm_data(file_path):
 | 
					def load_osm_data(file_path):
 | 
				
			||||||
    #Load OSM data from a GeoJSON file.
 | 
					    #Load OSM data from a GeoJSON file.
 | 
				
			||||||
    with open(file_path, "r", encoding="utf-8") as file:
 | 
					    with open(file_path, "r", encoding="utf-8") as file:
 | 
				
			||||||
        data = json.load(file)
 | 
					        data = json.load(file)
 | 
				
			||||||
    return data
 | 
					    return data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def transform_osm_data(feature):
 | 
					def transform_osm_data(feature):
 | 
				
			||||||
    #Transform a single OSM feature into the API payload format
 | 
					    #Transform a single OSM feature into the API payload format
 | 
				
			||||||
    prop = feature.get("properties", {})
 | 
					    prop = feature.get("properties", {})
 | 
				
			||||||
@@ -30,8 +32,9 @@ def transform_osm_data(feature):
 | 
				
			|||||||
        "external_source_id": "OSM"
 | 
					        "external_source_id": "OSM"
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def send_to_api(data):
 | 
					def send_to_api(data):
 | 
				
			||||||
    #Send transformed data to the Notfellchen API.
 | 
					    # Send transformed data to the Notfellchen API.
 | 
				
			||||||
    response = requests.post(ENDPOINT, headers=HEADERS, json=data)
 | 
					    response = requests.post(ENDPOINT, headers=HEADERS, json=data)
 | 
				
			||||||
    if response.status_code == 201:
 | 
					    if response.status_code == 201:
 | 
				
			||||||
        print(f"Success: Shelter '{data['name']}' uploaded.")
 | 
					        print(f"Success: Shelter '{data['name']}' uploaded.")
 | 
				
			||||||
@@ -44,7 +47,6 @@ def main():
 | 
				
			|||||||
    # Step 1: Load OSM data
 | 
					    # Step 1: Load OSM data
 | 
				
			||||||
    osm_data = load_osm_data(OSM_DATA_FILE)
 | 
					    osm_data = load_osm_data(OSM_DATA_FILE)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Step 2: Process each shelter and send it to the API
 | 
					    # Step 2: Process each shelter and send it to the API
 | 
				
			||||||
    for feature in osm_data.get("features", []):
 | 
					    for feature in osm_data.get("features", []):
 | 
				
			||||||
        shelter_data = transform_osm_data(feature)
 | 
					        shelter_data = transform_osm_data(feature)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user