@@ -28,7 +28,7 @@ def __init__(self):
2828 # Each word should be a 7-tuple:
2929 # (font, text, width, space, stretch, ascent, descent)
3030 def addword (self , d , font , text , space , stretch ):
31- if font <> None :
31+ if font is not None :
3232 d .setfont (font )
3333 width = d .textwidth (text )
3434 ascent = d .baseline ()
@@ -50,7 +50,7 @@ def end_anchor(self, id):
5050 def getlength (self ):
5151 total = 0
5252 for word in self .words :
53- if type (word ) <> Int :
53+ if type (word ) is not Int :
5454 total = total + word [2 ] + word [3 ]
5555 return total
5656 #
@@ -63,7 +63,7 @@ def tabto(self, tab):
6363 as , de = 1 , 0
6464 for i in range (len (self .words )):
6565 word = self .words [i ]
66- if type (word ) == Int : continue
66+ if type (word ) is Int : continue
6767 (fo , te , wi , sp , st , as , de ) = word
6868 self .words [i ] = (fo , te , wi , sp , 0 , as , de )
6969 total = total + wi + sp
@@ -99,15 +99,15 @@ def layout(self, linewidth):
9999 j = i
100100 while i < n :
101101 word = words [i ]
102- if type (word ) == Int :
102+ if type (word ) is Int :
103103 if word > 0 and width >= avail :
104104 break
105105 i = i + 1
106106 continue
107107 fo , te , wi , sp , st , as , de = word
108108 if width + wi > avail and width > 0 and wi > 0 :
109109 break
110- if fo <> None :
110+ if fo is not None :
111111 lastfont = fo
112112 if width == 0 :
113113 firstfont = fo
@@ -119,7 +119,7 @@ def layout(self, linewidth):
119119 ascent = max (ascent , as )
120120 descent = max (descent , de )
121121 i = i + 1
122- while i > j and type (words [i - 1 ]) == Int and \
122+ while i > j and type (words [i - 1 ]) is Int and \
123123 words [i - 1 ] > 0 : i = i - 1
124124 width = width - lsp
125125 if i < n :
@@ -152,10 +152,10 @@ def visit(self, wordfunc, anchorfunc):
152152 v2 = v + ascent + descent
153153 for j in range (i , i + wordcount ):
154154 word = self .words [j ]
155- if type (word ) == Int :
155+ if type (word ) is Int :
156156 ok = anchorfunc (self , tuple , word , \
157157 h , v )
158- if ok <> None : return ok
158+ if ok is not None : return ok
159159 continue
160160 fo , te , wi , sp , st , as , de = word
161161 if extra > 0 and stretch > 0 :
@@ -167,7 +167,7 @@ def visit(self, wordfunc, anchorfunc):
167167 h2 = h + wi + sp + ex
168168 ok = wordfunc (self , tuple , word , h , v , \
169169 h2 , v2 , (j == i ), (j == i + wordcount - 1 ))
170- if ok <> None : return ok
170+ if ok is not None : return ok
171171 h = h2
172172 v = v2
173173 i = i + wordcount
@@ -177,7 +177,7 @@ def visit(self, wordfunc, anchorfunc):
177177 # given by (left, top, right) with an unspecified bottom.
178178 # Return the computed bottom of the text.
179179 def render (self , d , left , top , right ):
180- if self .width <> right - left :
180+ if self .width != right - left :
181181 self .layout (right - left )
182182 self .left = left
183183 self .top = top
@@ -193,7 +193,7 @@ def render(self, d, left, top, right):
193193 return self .bottom
194194 #
195195 def _renderword (self , tuple , word , h , v , h2 , v2 , isfirst , islast ):
196- if word [0 ] <> None : self .d .setfont (word [0 ])
196+ if word [0 ] is not None : self .d .setfont (word [0 ])
197197 baseline = v + tuple [5 ]
198198 self .d .text ((h , baseline - word [5 ]), word [1 ])
199199 if self .anchorid > 0 :
@@ -229,7 +229,7 @@ def hasanchor(self, id):
229229 def extract (self ):
230230 text = ''
231231 for w in self .words :
232- if type (w ) <> Int :
232+ if type (w ) is not Int :
233233 word = w [1 ]
234234 if w [3 ]: word = word + ' '
235235 text = text + word
@@ -254,14 +254,14 @@ def whereis(self, d, mouseh, mousev):
254254 #
255255 def _whereisword (self , tuple , word , h1 , v1 , h2 , v2 , isfirst , islast ):
256256 fo , te , wi , sp , st , as , de = word
257- if fo <> None : self .lastfont = fo
257+ if fo is not None : self .lastfont = fo
258258 h = h1
259259 if isfirst : h1 = 0
260260 if islast : h2 = 999999
261261 if not (v1 <= self .mousev <= v2 and h1 <= self .mouseh <= h2 ):
262262 self .charcount = self .charcount + len (te ) + (sp > 0 )
263263 return
264- if self .lastfont <> None :
264+ if self .lastfont is not None :
265265 self .d .setfont (self .lastfont )
266266 cc = 0
267267 for c in te :
@@ -295,15 +295,15 @@ def screenpos(self, d, pos):
295295 self .__class__ ._screenposanchor )
296296 finally :
297297 self .d = None
298- if ok == None :
298+ if ok is None :
299299 ascent , descent = self .lines [- 1 ][5 :7 ]
300300 ok = self .right , self .bottom - ascent - descent , \
301301 self .bottom - descent , self .bottom
302302 return ok
303303 #
304304 def _screenposword (self , tuple , word , h1 , v1 , h2 , v2 , isfirst , islast ):
305305 fo , te , wi , sp , st , as , de = word
306- if fo <> None : self .lastfont = fo
306+ if fo is not None : self .lastfont = fo
307307 cc = len (te ) + (sp > 0 )
308308 if self .pos > cc :
309309 self .pos = self .pos - cc
@@ -324,11 +324,11 @@ def _screenposanchor(self, tuple, word, h, v):
324324 # if pos2 is None, the end is implied.
325325 # Undoes its own effect when called again with the same arguments
326326 def invert (self , d , pos1 , pos2 ):
327- if pos1 == None :
327+ if pos1 is None :
328328 pos1 = self .left , self .top , self .top , self .top
329329 else :
330330 pos1 = self .screenpos (d , pos1 )
331- if pos2 == None :
331+ if pos2 is None :
332332 pos2 = self .right , self .bottom ,self .bottom ,self .bottom
333333 else :
334334 pos2 = self .screenpos (d , pos2 )
0 commit comments