2to3 last remnants of Python 2 syntax
This commit is contained in:
parent
745e393fd6
commit
4b0bdd8630
4 changed files with 27 additions and 27 deletions
|
@ -3,8 +3,8 @@ import random
|
|||
|
||||
im = mapnik.Image(256,256)
|
||||
|
||||
for x in xrange(0,im.width()):
|
||||
for y in xrange(0,im.height()):
|
||||
for x in range(im.width()):
|
||||
for y in range(im.height()):
|
||||
r = int(random.random() * 255)
|
||||
g = random.random() * 255
|
||||
b = random.random() * 255
|
||||
|
|
|
@ -50,10 +50,10 @@ parser.add_option("-d", "--deadline",
|
|||
|
||||
def check_deadline(now):
|
||||
if options.deadline > 0 and options.deadline < now:
|
||||
print "\n\n*** travis-cmd-wrapper: deadline reached, shutting down ***\n\n"
|
||||
print("\n\n*** travis-cmd-wrapper: deadline reached, shutting down ***\n\n")
|
||||
sys.exit(1)
|
||||
else:
|
||||
print "deadline not reached: %s > %s" % (options.deadline,now)
|
||||
print("deadline not reached: %s > %s" % (options.deadline,now))
|
||||
|
||||
# Set up status alarm. When we have a deadline, we need to check more often
|
||||
# and/or sooner. Sending a SIGALRM manually will also trigger a status report
|
||||
|
@ -95,7 +95,7 @@ try:
|
|||
line = cmd.stdout.readline()
|
||||
sys.stdout.write(line)
|
||||
sys.stdout.flush()
|
||||
except IOError, ex:
|
||||
except IOError as ex:
|
||||
if ex.errno != errno.EINTR:
|
||||
raise
|
||||
finally:
|
||||
|
|
|
@ -46,7 +46,7 @@ if env['RUNTIME_LINK'] == 'static':
|
|||
cmd = 'pkg-config libpq --libs --static'
|
||||
try:
|
||||
program_env.ParseConfig(cmd)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
program_env.Append(LIBS='pq')
|
||||
else:
|
||||
program_env.Append(LIBS='pq')
|
||||
|
|
|
@ -22,7 +22,7 @@ ShapeType = { 0 : "NullShape",
|
|||
|
||||
def test_record(_type, record) :
|
||||
if _type == 0:
|
||||
print "NULL shape"
|
||||
print("NULL shape")
|
||||
elif _type == 11: #PointZ
|
||||
test_pointz(record)
|
||||
elif _type == 5:
|
||||
|
@ -31,35 +31,35 @@ def test_record(_type, record) :
|
|||
def test_pointz(record):
|
||||
_type, = struct.unpack("<i", record[0:4])
|
||||
if _type == 0:
|
||||
print "NULL shape"
|
||||
print("NULL shape")
|
||||
return
|
||||
if len(record) != 36 :
|
||||
print>>sys.stderr,"BAD SHAPE FILE: expected 36 bytes got",len(record)
|
||||
print("BAD SHAPE FILE: expected 36 bytes got", len(record), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
x,y,z,m = struct.unpack("<dddd",record[4:36])
|
||||
if _type != 11:
|
||||
print>>sys.stderr,"BAD SHAPE FILE: expected PointZ or NullShape got",_type
|
||||
print("BAD SHAPE FILE: expected PointZ or NullShape got", _type, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
def test_polygon(record):
|
||||
_type, = struct.unpack("<i", record[0:4])
|
||||
if _type == 0:
|
||||
print "NULL shape"
|
||||
print("NULL shape")
|
||||
return
|
||||
x0, y0, x1, y0, num_parts, num_points = struct.unpack("<ddddii", record[4:44])
|
||||
if _type != 5:
|
||||
print>>sys.stderr, "BAD SHAPE FILE: expected Polygon or NullShape got", _type
|
||||
print("BAD SHAPE FILE: expected Polygon or NullShape got", _type, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
length = len(record)
|
||||
rec_length = 44 + num_parts * 4 + num_points * 16
|
||||
if rec_length <> length:
|
||||
print>>sys.stderr, "BAD SHAPE FILE: expected", rec_length, "got", length
|
||||
if rec_length != length:
|
||||
print("BAD SHAPE FILE: expected", rec_length, "got", length, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__" :
|
||||
|
||||
if len(sys.argv) !=2:
|
||||
print>>sys.stderr, "Usage:",sys.argv[0],"<shapefile>"
|
||||
print("Usage:",sys.argv[0],"<shapefile>", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
shx_filename = sys.argv[1][:-3]+"shx"
|
||||
|
@ -80,15 +80,15 @@ if __name__ == "__main__" :
|
|||
version,_type,lox,loy,hix,hiy,_,_,_,_ = header[1].unpack_from(shp.read(72))
|
||||
|
||||
shp_bbox = [lox,loy,hix,hiy]
|
||||
if shx_bbox <> shp_bbox :
|
||||
print "BAD SHAPE FILE: bounding box mismatch in *.shp and *.shx", shp_bbox, shx_bbox
|
||||
if shx_bbox != shp_bbox :
|
||||
print("BAD SHAPE FILE: bounding box mismatch in *.shp and *.shx", shp_bbox, shx_bbox)
|
||||
sys.exit(1)
|
||||
|
||||
print "SHX FILE_LENGTH=",shx_file_length,"bytes"
|
||||
print "SHP FILE_LENGTH=",shp_file_length,"bytes"
|
||||
print("SHX FILE_LENGTH=",shx_file_length,"bytes")
|
||||
print("SHP FILE_LENGTH=",shp_file_length,"bytes")
|
||||
|
||||
print "TYPE", ShapeType[_type]
|
||||
print "BBOX(",lox,loy,hix,hiy,")"
|
||||
print("TYPE", ShapeType[_type])
|
||||
print("BBOX(",lox,loy,hix,hiy,")")
|
||||
record_header = struct.Struct(">II")
|
||||
record = struct.Struct(">II")
|
||||
calc_total_size = 50
|
||||
|
@ -97,19 +97,19 @@ if __name__ == "__main__" :
|
|||
offset,shx_content_length = record.unpack_from(shx.read(8))
|
||||
shp.seek(offset*2, os.SEEK_SET)
|
||||
record_number,content_length = record_header.unpack_from(shp.read(8))
|
||||
if shx_content_length <> content_length:
|
||||
print "BAD SHAPE FILE: content_lenght mismatch in SHP and SHX",shx_content_length,content_length
|
||||
if shx_content_length != content_length:
|
||||
print("BAD SHAPE FILE: content_lenght mismatch in SHP and SHX",shx_content_length,content_length)
|
||||
sys.exit(1)
|
||||
##
|
||||
test_record(_type, shp.read(2*content_length))
|
||||
calc_total_size +=(4 + content_length)
|
||||
count+=1
|
||||
|
||||
print "SHAPES COUNT=",count
|
||||
print("SHAPES COUNT=",count)
|
||||
delta = shp_file_length-calc_total_size
|
||||
if delta > 0 :
|
||||
print "BAD SHAPE FILE: extra ", 2*delta,"bytes"
|
||||
print("BAD SHAPE FILE: extra ", 2*delta,"bytes")
|
||||
elif delta < 0:
|
||||
print "BAD SHAPE FILE: missing ", 2*delta,"bytes"
|
||||
print("BAD SHAPE FILE: missing ", 2*delta,"bytes")
|
||||
else:
|
||||
print "SHAPE FILE LOOKS GOOD!"
|
||||
print("SHAPE FILE LOOKS GOOD!")
|
||||
|
|
Loading…
Reference in a new issue