mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Update the code to better reflect recommended style:
Use != instead of <> since <> is documented as "obsolescent". Use "is" and "is not" when comparing with None or type objects.
This commit is contained in:
parent
63596aeb33
commit
132dce2246
55 changed files with 520 additions and 519 deletions
|
@ -7,7 +7,7 @@ _v20 = 1
|
|||
_v21 = 1
|
||||
##import fl
|
||||
##try:
|
||||
## _v20 = (fl.get_rgbmode <> None)
|
||||
## _v20 = (fl.get_rgbmode is not None)
|
||||
##except:
|
||||
## _v20 = 0
|
||||
##del fl
|
||||
|
|
|
@ -77,7 +77,7 @@ class Cdplayer:
|
|||
line = old.readline()
|
||||
if line == '':
|
||||
break
|
||||
if line[:l] <> s:
|
||||
if line[:l] != s:
|
||||
new.write(line)
|
||||
new.write(self.id + '.title:\t' + self.title + '\n')
|
||||
new.write(self.id + '.artist:\t' + self.artist + '\n')
|
||||
|
|
|
@ -36,7 +36,7 @@ def parse_form(filename, formname):
|
|||
#
|
||||
def parse_forms(filename):
|
||||
forms = checkcache(filename)
|
||||
if forms != None: return forms
|
||||
if forms is not None: return forms
|
||||
fp = _open_formfile(filename)
|
||||
nforms = _parse_fd_header(fp)
|
||||
forms = {}
|
||||
|
@ -168,7 +168,7 @@ def _open_formfile(filename):
|
|||
return _open_formfile2(filename)[0]
|
||||
|
||||
def _open_formfile2(filename):
|
||||
if filename[-3:] <> '.fd':
|
||||
if filename[-3:] != '.fd':
|
||||
filename = filename + '.fd'
|
||||
if filename[0] == '/':
|
||||
try:
|
||||
|
@ -184,7 +184,7 @@ def _open_formfile2(filename):
|
|||
break
|
||||
except IOError:
|
||||
fp = None
|
||||
if fp == None:
|
||||
if fp is None:
|
||||
raise error, 'Cannot find forms file ' + filename
|
||||
return fp, filename
|
||||
|
||||
|
@ -194,7 +194,7 @@ def _open_formfile2(filename):
|
|||
def _parse_fd_header(file):
|
||||
# First read the magic header line
|
||||
datum = _parse_1_line(file)
|
||||
if datum <> ('Magic', 12321):
|
||||
if datum != ('Magic', 12321):
|
||||
raise error, 'Not a forms definition file'
|
||||
# Now skip until we know number of forms
|
||||
while 1:
|
||||
|
@ -208,10 +208,10 @@ def _parse_fd_header(file):
|
|||
#
|
||||
def _parse_fd_form(file, name):
|
||||
datum = _parse_1_line(file)
|
||||
if datum <> FORMLINE:
|
||||
if datum != FORMLINE:
|
||||
raise error, 'Missing === FORM === line'
|
||||
form = _parse_object(file)
|
||||
if form.Name == name or name == None:
|
||||
if form.Name == name or name is None:
|
||||
objs = []
|
||||
for j in range(form.Numberofobjects):
|
||||
obj = _parse_object(file)
|
||||
|
@ -316,7 +316,7 @@ def _parse_object(file):
|
|||
if datum == FORMLINE:
|
||||
file.seek(pos)
|
||||
return obj
|
||||
if type(datum) <> type(()) or len(datum) <> 2:
|
||||
if type(datum) is not type(()) or len(datum) != 2:
|
||||
raise error, 'Parse error, illegal line in object: '+datum
|
||||
obj.add(datum[0], datum[1])
|
||||
|
||||
|
@ -339,7 +339,7 @@ def create_full_form(inst, (fdata, odatalist)):
|
|||
#
|
||||
def merge_full_form(inst, form, (fdata, odatalist)):
|
||||
exec 'inst.'+fdata.Name+' = form\n'
|
||||
if odatalist[0].Class <> FL.BOX:
|
||||
if odatalist[0].Class != FL.BOX:
|
||||
raise error, 'merge_full_form() expects FL.BOX as first obj'
|
||||
for odata in odatalist[1:]:
|
||||
create_object_instance(inst, form, odata)
|
||||
|
|
|
@ -59,7 +59,7 @@ def decompress(jpegdata):
|
|||
return imgdata, width, height, bytesperpixel
|
||||
|
||||
def setoption(name, value):
|
||||
if type(value) <> type(0):
|
||||
if type(value) is not type(0):
|
||||
raise TypeError, 'jpeg.setoption: numeric options only'
|
||||
if name == 'forcegrey':
|
||||
name = 'forcegray'
|
||||
|
|
|
@ -207,7 +207,7 @@ def build_panel(descr):
|
|||
#
|
||||
# Sanity check
|
||||
#
|
||||
if (not descr) or descr[0] <> 'panel':
|
||||
if (not descr) or descr[0] != 'panel':
|
||||
raise panel_error, 'panel description must start with "panel"'
|
||||
#
|
||||
if debug: show_panel('', descr)
|
||||
|
|
|
@ -71,7 +71,7 @@ syntax_error = 'syntax error'
|
|||
# May raise syntax_error.
|
||||
#
|
||||
def parse_expr(tokens):
|
||||
if (not tokens) or tokens[0] <> '(':
|
||||
if (not tokens) or tokens[0] != '(':
|
||||
raise syntax_error, 'expected "("'
|
||||
tokens = tokens[1:]
|
||||
expr = []
|
||||
|
|
|
@ -93,7 +93,7 @@ class Readcd:
|
|||
if prog < self.status[5] or prog > self.status[6]:
|
||||
raise Error, 'range error'
|
||||
end = self.pmsf2msf(prog, min, sec, frame)
|
||||
elif l <> 3:
|
||||
elif l != 3:
|
||||
raise Error, 'syntax error'
|
||||
if type(start) == type(0):
|
||||
if start < self.status[5] or start > self.status[6]:
|
||||
|
@ -111,7 +111,7 @@ class Readcd:
|
|||
if prog < self.status[5] or prog > self.status[6]:
|
||||
raise Error, 'range error'
|
||||
start = self.pmsf2msf(prog, min, sec, frame)
|
||||
elif l <> 3:
|
||||
elif l != 3:
|
||||
raise Error, 'syntax error'
|
||||
self.list.append((start, end))
|
||||
|
||||
|
@ -127,10 +127,10 @@ class Readcd:
|
|||
if self.playing:
|
||||
start, end = self.list[self.listindex]
|
||||
if type(end) == type(0):
|
||||
if cb_type <> CD.PNUM:
|
||||
if cb_type != CD.PNUM:
|
||||
self.parser.setcallback(cb_type, func, arg)
|
||||
else:
|
||||
if cb_type <> CD.ATIME:
|
||||
if cb_type != CD.ATIME:
|
||||
self.parser.setcallback(cb_type, func, arg)
|
||||
|
||||
def removecallback(self, cb_type):
|
||||
|
@ -140,10 +140,10 @@ class Readcd:
|
|||
if self.playing:
|
||||
start, end = self.list[self.listindex]
|
||||
if type(end) == type(0):
|
||||
if cb_type <> CD.PNUM:
|
||||
if cb_type != CD.PNUM:
|
||||
self.parser.removecallback(cb_type)
|
||||
else:
|
||||
if cb_type <> CD.ATIME:
|
||||
if cb_type != CD.ATIME:
|
||||
self.parser.removecallback(cb_type)
|
||||
|
||||
def gettrackinfo(self, *arg):
|
||||
|
|
|
@ -60,7 +60,7 @@ def torgb(filename):
|
|||
ret = _torgb(filename, temps)
|
||||
finally:
|
||||
for temp in temps[:]:
|
||||
if temp <> ret:
|
||||
if temp != ret:
|
||||
try:
|
||||
os.unlink(temp)
|
||||
except os.error:
|
||||
|
@ -83,12 +83,12 @@ def _torgb(filename, temps):
|
|||
if type(msg) == type(()) and len(msg) == 2 and \
|
||||
type(msg[0]) == type(0) and type(msg[1]) == type(''):
|
||||
msg = msg[1]
|
||||
if type(msg) <> type(''):
|
||||
if type(msg) is not type(''):
|
||||
msg = `msg`
|
||||
raise error, filename + ': ' + msg
|
||||
if ftype == 'rgb':
|
||||
return fname
|
||||
if ftype == None or not table.has_key(ftype):
|
||||
if ftype is None or not table.has_key(ftype):
|
||||
raise error, \
|
||||
filename + ': unsupported image file type ' + `ftype`
|
||||
temp = tempfile.mktemp()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue