1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 01:48:00 +00:00

mkicon.py: Avoid dict.has_key.

"key in dict" was introduced in Python 2.2, and the older
"dict.has_key(key)" form was removed in Python 3.  Use the more portable
"key in dict" form instead.
This commit is contained in:
Colin Watson 2019-08-30 13:41:10 +01:00 committed by Simon Tatham
parent 0f60c244e8
commit b810de5f3a

View File

@ -70,7 +70,7 @@ def render(canvas, minx, miny, maxx, maxy):
sqrthash = {} sqrthash = {}
def memoisedsqrt(x): def memoisedsqrt(x):
if not sqrthash.has_key(x): if x not in sqrthash:
sqrthash[x] = math.sqrt(x) sqrthash[x] = math.sqrt(x)
return sqrthash[x] return sqrthash[x]
@ -165,7 +165,7 @@ def border(canvas, thickness, squarecorners, out={}):
bvalues[(x+dx,y+dy)] = bval bvalues[(x+dx,y+dy)] = bval
for (x, y), value in bvalues.items(): for (x, y), value in bvalues.items():
if not canvas.has_key((x,y)): if (x,y) not in canvas:
canvas[(x,y)] = dark(value) canvas[(x,y)] = dark(value)
def sysbox(size, out={}): def sysbox(size, out={}):
@ -483,11 +483,11 @@ def hat(size):
grey = bothere - tophere grey = bothere - tophere
# Only draw brim pixels over pixels which are (a) part # Only draw brim pixels over pixels which are (a) part
# of the main hat, and (b) not right on its edge. # of the main hat, and (b) not right on its edge.
if canvas.has_key((x,y)) and \ if (x,y) in canvas and \
canvas.has_key((x,y-1)) and \ (x,y-1) in canvas and \
canvas.has_key((x,y+1)) and \ (x,y+1) in canvas and \
canvas.has_key((x-1,y)) and \ (x-1,y) in canvas and \
canvas.has_key((x+1,y)): (x+1,y) in canvas:
pixel(x, y, greypix(grey), canvas) pixel(x, y, greypix(grey), canvas)
return canvas return canvas
@ -865,7 +865,7 @@ def pageant_icon(size):
yrelmin = None yrelmin = None
for cx in cty.keys(): for cx in cty.keys():
hx = cx - xrel hx = cx - xrel
assert hty.has_key(hx) assert hx in hty
yrel = cty[cx] - hty[hx] yrel = cty[cx] - hty[hx]
if yrelmin == None: if yrelmin == None:
yrelmin = yrel yrelmin = yrel