Skip to content

Commit

Permalink
Switch init_pbf.py to python3
Browse files Browse the repository at this point in the history
  • Loading branch information
jocelynj committed Oct 10, 2020
1 parent 70978fa commit 6d2f331
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
6 changes: 6 additions & 0 deletions osc_modif/configuration-planet.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# The URL of the directory containing change files.
baseUrl=file:///data/work/osmbin/replication/diffs/planet/minute

# Defines the maximum time interval in seconds to download in a single invocation.
# Setting to 0 disables this feature.
maxInterval=2592000
18 changes: 9 additions & 9 deletions osc_modif/init_pbf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#-*- coding: utf-8 -*-

###########################################################################
Expand Down Expand Up @@ -40,15 +40,15 @@

def init_pbf(dirpath, filenames, options):
cmd = [osmosis_bin]
print dirpath
print(dirpath)
if dirpath == ".":
orig_pbf = planet_file
else:
orig_pbf = os.path.join(work_pbfs_path, dirpath, os.path.basename(dirpath) + ".osm.pbf")
if not os.path.isfile(orig_pbf):
up = os.path.dirname(os.path.dirname(orig_pbf))
orig_pbf = os.path.join(up, os.path.basename(up) + ".osm.pbf")
print orig_pbf
print(orig_pbf)
need_launch = False
country_dir = {}
pwd = os.getcwd()
Expand All @@ -66,7 +66,7 @@ def init_pbf(dirpath, filenames, options):

if options.country and f.split(".")[0] not in options.country:
continue
print f
print(f)
need_launch = True
dst_poly = os.path.join(pwd, dirpath, f)
dst_pbf = os.path.join(country_dir[f], ".".join(f.split(".")[:-1]) + ".osm.tmp.pbf")
Expand Down Expand Up @@ -95,7 +95,7 @@ def init_pbf(dirpath, filenames, options):
return

# Create configuration.txt
orig_configuration = os.path.join(os.path.dirname(planet_file), "configuration.txt")
orig_configuration = "../configuration-planet.txt"
orig_lines = []
with open(orig_configuration, "r") as src_f:
for l in src_f:
Expand All @@ -121,19 +121,19 @@ def init_pbf(dirpath, filenames, options):
if run == num_runs-1:
last = len(osmium_config_list)

print " run %d with %d countries" % (run, last-first)
print(" run %d with %d countries" % (run, last-first))
osmium_config = "".join(osmium_config_list[first:last])
with open(osmium_config_file, "w") as f:
f.write(osmium_config_begin)
f.write(osmium_config)
f.write(osmium_config_end)
print osmium_cmd
print(osmium_cmd)
subprocess.check_call(osmium_cmd)

first = last
last += len(osmium_config_list) // num_runs
else:
print cmd
print(cmd)
subprocess.check_call(cmd)

for f in filenames:
Expand Down Expand Up @@ -183,6 +183,6 @@ def init_pbf(dirpath, filenames, options):
region = r[2:]

if args.list_region:
print region
print(region)
elif not args.region or region in args.region:
init_pbf(r, files, args)

0 comments on commit 6d2f331

Please sign in to comment.