mirror of
https://github.com/oDinZu/natural-earth-vector.git
synced 2025-02-23 00:02:17 -05:00
switch to HTTPS, tabs to spaces, add progress reporting
This commit is contained in:
parent
bca7fb5ca4
commit
c327c3dc8c
@ -4,6 +4,7 @@ from shapely.geometry import shape, mapping
|
|||||||
import requests
|
import requests
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
|
import sys
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ args = parser.parse_args()
|
|||||||
|
|
||||||
def generate_id():
|
def generate_id():
|
||||||
|
|
||||||
url = 'http://api.brooklynintegers.com/rest/'
|
url = 'https://api.brooklynintegers.com/rest/'
|
||||||
params = {'method':'brooklyn.integers.create'}
|
params = {'method':'brooklyn.integers.create'}
|
||||||
|
|
||||||
try :
|
try :
|
||||||
@ -52,7 +53,15 @@ with fiona.open( args.input, 'r', encoding='utf-8' ) as source:
|
|||||||
schema=sink_schema,
|
schema=sink_schema,
|
||||||
) as sink:
|
) as sink:
|
||||||
|
|
||||||
|
# setup counter to track which feature we're on
|
||||||
|
f_counter = 1
|
||||||
|
total_features = len(list(source))
|
||||||
|
|
||||||
for feature in source:
|
for feature in source:
|
||||||
|
# report which feature we're processing
|
||||||
|
sys.stdout.write("\r " + str(f_counter) + " of " + str(total_features))
|
||||||
|
# but don't spam with new lines
|
||||||
|
sys.stdout.flush()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
@ -79,4 +88,7 @@ with fiona.open( args.input, 'r', encoding='utf-8' ) as source:
|
|||||||
except Exception, e:
|
except Exception, e:
|
||||||
logging.exception("Error processing feature %s:", feature['id'])
|
logging.exception("Error processing feature %s:", feature['id'])
|
||||||
|
|
||||||
|
# increment counter
|
||||||
|
f_counter += 1
|
||||||
|
|
||||||
# The sink file is written to disk and closed when its block ends.
|
# The sink file is written to disk and closed when its block ends.
|
Loading…
x
Reference in New Issue
Block a user