Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions python-samples/batchimport/batch_import_locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,10 @@ def import_batch(batch, use_put=False):
try:
woosmap_location = datagov2woosmap(location, "ID" + str(id))

batch.append(woosmap_location)
if len(batch) == batch_size:
batch_result = import_batch(batch, use_put=update_location)
batch = []
else:
batch.append(woosmap_location)

except InvalidGeometry:
pass
Expand Down
11 changes: 5 additions & 6 deletions python-samples/woosmap_to_woosmap/woosmap_to_woosmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def transform_geojson_woosmap(extracted_geojson):
"name": prop.get("name", ""),
"tags": prop.get("tags", []),
"contact": prop.get("contact", {})})
except BaseException as error:
print('An exception occurred: {}'.format(error))
except Exception as err:
print('An exception occurred: {}'.format(err))

return stores

Expand Down Expand Up @@ -90,15 +90,14 @@ def import_location(locations):
export_input_json(stores_woosmap)
if private_key:
for store in stores_woosmap:
batch.append(store)
if len(batch) == stores_batch_size:
batch_result = import_location(batch)
batch = []
else:
batch.append(store)

if batch:
batch_result = import_location(batch)
batch = []

except BaseException as error: # bad bad way!
print('An exception occurred: {}'.format(error))
except Exception as err:
print('An exception occurred: {}'.format(err))