Skip to content

Commit ab7153e

Browse files
authored
Merge pull request #24 from interline-io/python3fixes
Fix python3 errors
2 parents 2e2fd1b + a8af3fb commit ab7153e

File tree

6 files changed

+31
-13
lines changed

6 files changed

+31
-13
lines changed

planetutils/elevation_tile_download.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
from __future__ import absolute_import, unicode_literals
2+
from __future__ import absolute_import, unicode_literals, print_function
33
import argparse
44
import sys
55

@@ -26,7 +26,7 @@ def main():
2626
elif args.format == 'skadi':
2727
p = ElevationSkadiDownloader(args.outpath)
2828
else:
29-
print "Unknown format: %s"%args.format
29+
print("Unknown format: %s"%args.format)
3030
sys.exit(1)
3131

3232
if args.csv:

planetutils/elevation_tile_downloader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def get_bbox_tiles(self, bbox):
8787
return tiles
8888

8989
def tile_path(self, z, x, y):
90-
return map(str, [z, x, str(y)+'.tif'])
90+
return list(map(str, [z, x, str(y)+'.tif']))
9191

9292
class ElevationSkadiDownloader(ElevationDownloader):
9393
HGT_SIZE = (3601 * 3601 * 2)

planetutils/elevation_tile_merge.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
from __future__ import absolute_import, unicode_literals
2+
from __future__ import absolute_import, unicode_literals, print_function
33
import argparse
44
import sys
55
import fnmatch
@@ -20,7 +20,7 @@ def main():
2020
tmppath = args.outpath
2121

2222
if args.scale and len(args.scale.split(',')) != 2:
23-
print "Must provide min, max values"
23+
print("Must provide min, max values")
2424
sys.exit(1)
2525
elif args.scale:
2626
# Output to tmp file
@@ -32,22 +32,22 @@ def main():
3232
matches.append(os.path.join(root, filename))
3333

3434
if len(matches) == 0:
35-
print "No input files"
35+
print("No input files")
3636
sys.exit(0)
3737

38-
print "Found %s files:"%len(matches)
38+
print("Found %s files:"%len(matches))
3939
for i in matches:
40-
print "\t%s"%(i)
40+
print("\t%s"%(i))
4141

4242
# gdal_merge.py -init 0 -o out.tif
43-
print "Merging... %s"%(tmppath)
43+
print("Merging... %s"%(tmppath))
4444
cmd = ['gdal_merge.py', '-init', '0', '-o', tmppath]
4545
cmd += matches
4646
p = subprocess.check_call(cmd)
4747

4848
# gdal_translate -of GTiff -ot Byte -scale 0 255 0 255 out.tif out8.tif
4949
if args.scale:
50-
print "Scaling: %s -> %s"%(tmppath, outpath)
50+
print("Scaling: %s -> %s"%(tmppath, outpath))
5151
a = args.scale.split(",")
5252
cmd = ['gdal_translate', '-of', 'GTiff', '-ot', 'Byte', '-scale', a[0], a[1], '0', '255', tmppath, outpath]
5353
subprocess.check_call(cmd)

planetutils/tilepack_download.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import argparse
55

66
from . import log
7-
from . import tilepack
87
from .bbox import bbox_string, load_bboxes_csv
98
from .tilepack_downloader import TilepackDownloader
109

planetutils/tilepack_downloader.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
from urllib.request import urlopen
66

77
import os
8-
import urlparse
98
import subprocess
109
import json
1110

12-
1311
from . import log
1412
from . import download
1513

tests/test_commands.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from __future__ import absolute_import, unicode_literals
2+
import tempfile
3+
import types
4+
import os
5+
import unittest
6+
7+
class TestCommandImports(unittest.TestCase):
8+
def test_command_imports(self):
9+
commands = [
10+
'osm_planet_update=planetutils.osm_planet_update:main',
11+
'osm_planet_extract=planetutils.osm_planet_extract:main',
12+
'osm_planet_get_timestamp=planetutils.osm_planet_get_timestamp:main',
13+
'osm_extract_download=planetutils.osm_extract_download:main',
14+
'elevation_tile_download=planetutils.elevation_tile_download:main',
15+
'elevation_tile_merge=planetutils.elevation_tile_merge:main',
16+
'valhalla_tilepack_download=planetutils.tilepack_download:main',
17+
'valhalla_tilepack_list=planetutils.tilepack_list:main'
18+
]
19+
for i in commands:
20+
a, _, b = i.partition('=')[-1].partition(':')
21+
exec('import %s'%(a))

0 commit comments

Comments
 (0)