[Python-checkins] CVS: python/dist/src/Lib/lib-old Para.py,1.6,1.7 cmp.py,1.1,1.2 cmpcache.py,1.1,1.2 dircmp.py,1.1,1.2 fmt.py,1.5,1.6 grep.py,1.7,1.8 packmail.py,1.7,1.8 tb.py,1.7,1.8 zmod.py,1.1,1.2

Fred L. Drake python-dev@python.org
Tue, 12 Dec 2000 15:11:44 -0800


Update of /cvsroot/python/python/dist/src/Lib/lib-old
In directory slayer.i.sourceforge.net:/tmp/cvs-serv18670/lib-old

Modified Files:
	Para.py cmp.py cmpcache.py dircmp.py fmt.py grep.py 
	packmail.py tb.py zmod.py 
Log Message:

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.


Index: Para.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/Para.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** Para.py	2000/07/16 12:04:31	1.6
--- Para.py	2000/12/12 23:11:41	1.7
***************
*** 29,33 ****
  	# (font, text, width, space, stretch, ascent, descent)
  	def addword(self, d, font, text, space, stretch):
! 		if font <> None:
  			d.setfont(font)
  		width = d.textwidth(text)
--- 29,33 ----
  	# (font, text, width, space, stretch, ascent, descent)
  	def addword(self, d, font, text, space, stretch):
! 		if font is not None:
  			d.setfont(font)
  		width = d.textwidth(text)
***************
*** 51,55 ****
  		total = 0
  		for word in self.words:
! 			if type(word) <> Int:
  				total = total + word[2] + word[3]
  		return total
--- 51,55 ----
  		total = 0
  		for word in self.words:
! 			if type(word) is not Int:
  				total = total + word[2] + word[3]
  		return total
***************
*** 64,68 ****
  		for i in range(len(self.words)):
  			word = self.words[i]
! 			if type(word) == Int: continue
  			(fo, te, wi, sp, st, as, de) = word
  			self.words[i] = (fo, te, wi, sp, 0, as, de)
--- 64,68 ----
  		for i in range(len(self.words)):
  			word = self.words[i]
! 			if type(word) is Int: continue
  			(fo, te, wi, sp, st, as, de) = word
  			self.words[i] = (fo, te, wi, sp, 0, as, de)
***************
*** 100,104 ****
  			while i < n:
  				word = words[i]
! 				if type(word) == Int:
  					if word > 0 and width >= avail:
  						break
--- 100,104 ----
  			while i < n:
  				word = words[i]
! 				if type(word) is Int:
  					if word > 0 and width >= avail:
  						break
***************
*** 108,112 ****
  				if width + wi > avail and width > 0 and wi > 0:
  					break
! 				if fo <> None:
  					lastfont = fo
  					if width == 0:
--- 108,112 ----
  				if width + wi > avail and width > 0 and wi > 0:
  					break
! 				if fo is not None:
  					lastfont = fo
  					if width == 0:
***************
*** 120,124 ****
  				descent = max(descent, de)
  				i = i+1
! 			while i > j and type(words[i-1]) == Int and \
  				words[i-1] > 0: i = i-1
  			width = width - lsp
--- 120,124 ----
  				descent = max(descent, de)
  				i = i+1
! 			while i > j and type(words[i-1]) is Int and \
  				words[i-1] > 0: i = i-1
  			width = width - lsp
***************
*** 153,160 ****
  			for j in range(i, i+wordcount):
  				word = self.words[j]
! 				if type(word) == Int:
  					ok = anchorfunc(self, tuple, word, \
  							h, v)
! 					if ok <> None: return ok
  					continue
  				fo, te, wi, sp, st, as, de = word
--- 153,160 ----
  			for j in range(i, i+wordcount):
  				word = self.words[j]
! 				if type(word) is Int:
  					ok = anchorfunc(self, tuple, word, \
  							h, v)
! 					if ok is not None: return ok
  					continue
  				fo, te, wi, sp, st, as, de = word
***************
*** 168,172 ****
  				ok = wordfunc(self, tuple, word, h, v, \
  					h2, v2, (j==i), (j==i+wordcount-1))
! 				if ok <> None: return ok
  				h = h2
  			v = v2
--- 168,172 ----
  				ok = wordfunc(self, tuple, word, h, v, \
  					h2, v2, (j==i), (j==i+wordcount-1))
! 				if ok is not None: return ok
  				h = h2
  			v = v2
***************
*** 178,182 ****
  	# Return the computed bottom of the text.
  	def render(self, d, left, top, right):
! 		if self.width <> right-left:
  			self.layout(right-left)
  		self.left = left
--- 178,182 ----
  	# Return the computed bottom of the text.
  	def render(self, d, left, top, right):
! 		if self.width != right-left:
  			self.layout(right-left)
  		self.left = left
***************
*** 194,198 ****
  	#
  	def _renderword(self, tuple, word, h, v, h2, v2, isfirst, islast):
! 		if word[0] <> None: self.d.setfont(word[0])
  		baseline = v + tuple[5]
  		self.d.text((h, baseline - word[5]), word[1])
--- 194,198 ----
  	#
  	def _renderword(self, tuple, word, h, v, h2, v2, isfirst, islast):
! 		if word[0] is not None: self.d.setfont(word[0])
  		baseline = v + tuple[5]
  		self.d.text((h, baseline - word[5]), word[1])
***************
*** 230,234 ****
  		text = ''
  		for w in self.words:
! 			if type(w) <> Int:
  				word = w[1]
  				if w[3]: word = word + ' '
--- 230,234 ----
  		text = ''
  		for w in self.words:
! 			if type(w) is not Int:
  				word = w[1]
  				if w[3]: word = word + ' '
***************
*** 255,259 ****
  	def _whereisword(self, tuple, word, h1, v1, h2, v2, isfirst, islast):
  		fo, te, wi, sp, st, as, de = word
! 		if fo <> None: self.lastfont = fo
  		h = h1
  		if isfirst: h1 = 0
--- 255,259 ----
  	def _whereisword(self, tuple, word, h1, v1, h2, v2, isfirst, islast):
  		fo, te, wi, sp, st, as, de = word
! 		if fo is not None: self.lastfont = fo
  		h = h1
  		if isfirst: h1 = 0
***************
*** 262,266 ****
  			self.charcount = self.charcount + len(te) + (sp > 0)
  			return
! 		if self.lastfont <> None:
  			self.d.setfont(self.lastfont)
  		cc = 0
--- 262,266 ----
  			self.charcount = self.charcount + len(te) + (sp > 0)
  			return
! 		if self.lastfont is not None:
  			self.d.setfont(self.lastfont)
  		cc = 0
***************
*** 296,300 ****
  		finally:
  			self.d = None
! 		if ok == None:
  			ascent, descent = self.lines[-1][5:7]
  			ok = self.right, self.bottom - ascent - descent, \
--- 296,300 ----
  		finally:
  			self.d = None
! 		if ok is None:
  			ascent, descent = self.lines[-1][5:7]
  			ok = self.right, self.bottom - ascent - descent, \
***************
*** 304,308 ****
  	def _screenposword(self, tuple, word, h1, v1, h2, v2, isfirst, islast):
  		fo, te, wi, sp, st, as, de = word
! 		if fo <> None: self.lastfont = fo
  		cc = len(te) + (sp > 0)
  		if self.pos > cc:
--- 304,308 ----
  	def _screenposword(self, tuple, word, h1, v1, h2, v2, isfirst, islast):
  		fo, te, wi, sp, st, as, de = word
! 		if fo is not None: self.lastfont = fo
  		cc = len(te) + (sp > 0)
  		if self.pos > cc:
***************
*** 325,333 ****
  	# Undoes its own effect when called again with the same arguments
  	def invert(self, d, pos1, pos2):
! 		if pos1 == None:
  			pos1 = self.left, self.top, self.top, self.top
  		else:
  			pos1 = self.screenpos(d, pos1)
! 		if pos2 == None:
  			pos2 = self.right, self.bottom,self.bottom,self.bottom
  		else:
--- 325,333 ----
  	# Undoes its own effect when called again with the same arguments
  	def invert(self, d, pos1, pos2):
! 		if pos1 is None:
  			pos1 = self.left, self.top, self.top, self.top
  		else:
  			pos1 = self.screenpos(d, pos1)
! 		if pos2 is None:
  			pos2 = self.right, self.bottom,self.bottom,self.bottom
  		else:

Index: cmp.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/cmp.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** cmp.py	2000/02/03 15:25:32	1.1
--- cmp.py	2000/12/12 23:11:41	1.2
***************
*** 17,21 ****
      Raise exceptions if either file could not be statted, read, etc."""
      s1, s2 = sig(os.stat(f1)), sig(os.stat(f2))
!     if s1[0] <> 8 or s2[0] <> 8:
          # Either is a not a plain file -- always report as different
          return 0
--- 17,21 ----
      Raise exceptions if either file could not be statted, read, etc."""
      s1, s2 = sig(os.stat(f1)), sig(os.stat(f2))
!     if s1[0] != 8 or s2[0] != 8:
          # Either is a not a plain file -- always report as different
          return 0
***************
*** 23,27 ****
          # type, size & mtime match -- report same
          return 1
!     if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother
          # types or sizes differ -- report different
          return 0
--- 23,27 ----
          # type, size & mtime match -- report same
          return 1
!     if s1[:2] != s2[:2]: # Types or sizes differ, don't bother
          # types or sizes differ -- report different
          return 0
***************
*** 60,63 ****
          b1 = fp1.read(bufsize)
          b2 = fp2.read(bufsize)
!         if b1 <> b2: return 0
          if not b1: return 1
--- 60,63 ----
          b1 = fp1.read(bufsize)
          b2 = fp2.read(bufsize)
!         if b1 != b2: return 0
          if not b1: return 1

Index: cmpcache.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/cmpcache.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** cmpcache.py	2000/02/03 15:25:32	1.1
--- cmpcache.py	2000/12/12 23:11:41	1.2
***************
*** 31,35 ****
          # type, size & mtime match -- report same
          return 1
!     if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother
          # types or sizes differ -- report different
          return 0
--- 31,35 ----
          # type, size & mtime match -- report same
          return 1
!     if s1[:2] != s2[:2]: # Types or sizes differ, don't bother
          # types or sizes differ -- report different
          return 0
***************
*** 61,64 ****
          b1 = fp1.read(bufsize)
          b2 = fp2.read(bufsize)
!         if b1 <> b2: return 0
          if not b1: return 1
--- 61,64 ----
          b1 = fp1.read(bufsize)
          b2 = fp2.read(bufsize)
!         if b1 != b2: return 0
          if not b1: return 1

Index: dircmp.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/dircmp.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** dircmp.py	2000/02/03 15:25:32	1.1
--- dircmp.py	2000/12/12 23:11:41	1.2
***************
*** 71,75 ****
                  a_type = S_IFMT(a_stat[ST_MODE])
                  b_type = S_IFMT(b_stat[ST_MODE])
!                 if a_type <> b_type:
                      self.common_funny.append(x)
                  elif S_ISDIR(a_type):
--- 71,75 ----
                  a_type = S_IFMT(a_stat[ST_MODE])
                  b_type = S_IFMT(b_stat[ST_MODE])
!                 if a_type != b_type:
                      self.common_funny.append(x)
                  elif S_ISDIR(a_type):
***************
*** 190,194 ****
      import getopt
      options, args = getopt.getopt(sys.argv[1:], 'r')
!     if len(args) <> 2: raise getopt.error, 'need exactly two args'
      dd = dircmp().new(args[0], args[1])
      dd.run()
--- 190,195 ----
      import getopt
      options, args = getopt.getopt(sys.argv[1:], 'r')
!     if len(args) != 2:
!         raise getopt.error, 'need exactly two args'
      dd = dircmp().new(args[0], args[1])
      dd.run()

Index: fmt.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/fmt.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** fmt.py	2000/02/27 15:34:29	1.5
--- fmt.py	2000/12/12 23:11:41	1.6
***************
*** 69,73 ****
  			p = self.paralist[i]
  			result = p.whereis(d, h, v)
! 			if result <> None:
  				return i, result
  		return None
--- 69,73 ----
  			p = self.paralist[i]
  			result = p.whereis(d, h, v)
! 			if result is not None:
  				return i, result
  		return None
***************
*** 76,80 ****
  		i, offset = long1
  		text = self.paralist[i].extract()
! 		while offset > 0 and text[offset-1] <> ' ': offset = offset-1
  		long1 = i, offset
  		#
--- 76,80 ----
  		i, offset = long1
  		text = self.paralist[i].extract()
! 		while offset > 0 and text[offset-1] != ' ': offset = offset-1
  		long1 = i, offset
  		#
***************
*** 82,86 ****
  		text = self.paralist[i].extract()
  		n = len(text)
! 		while offset < n-1 and text[offset] <> ' ': offset = offset+1
  		long2 = i, offset
  		#
--- 82,86 ----
  		text = self.paralist[i].extract()
  		n = len(text)
! 		while offset < n-1 and text[offset] != ' ': offset = offset+1
  		long2 = i, offset
  		#
***************
*** 160,164 ****
  	#
  	def setfont(self, font):
! 		if font == None: return
  		self.font = self.nextfont = font
  		d = self.d
--- 160,164 ----
  	#
  	def setfont(self, font):
! 		if font is None: return
  		self.font = self.nextfont = font
  		d = self.d
***************
*** 194,198 ****
  			self.b.addpara(self.para)
  			self.para = None
! 			if self.font <> None:
  				self.d.setfont(self.font)
  		self.nospace = 1
--- 194,198 ----
  			self.b.addpara(self.para)
  			self.para = None
! 			if self.font is not None:
  				self.d.setfont(self.font)
  		self.nospace = 1
***************
*** 339,344 ****
  	for i in range(len(para.words)):
  		fo, te, wi = para.words[i][:3]
! 		if fo <> None: curfont = fo
! 		if curfont <> oldfont:
  			if closechar.has_key(oldfont):
  				c = closechar[oldfont]
--- 339,344 ----
  	for i in range(len(para.words)):
  		fo, te, wi = para.words[i][:3]
! 		if fo is not None: curfont = fo
! 		if curfont != oldfont:
  			if closechar.has_key(oldfont):
  				c = closechar[oldfont]
***************
*** 431,435 ****
  			pos2 = long2[:3]
  			new = pos1, pos2
! 		if new <> self.selection:
  			d = self.window.begindrawing()
  			if self.selection:
--- 431,435 ----
  			pos2 = long2[:3]
  			new = pos1, pos2
! 		if new != self.selection:
  			d = self.window.begindrawing()
  			if self.selection:
***************
*** 463,467 ****
  	def search(self, prog):
  		import re, string
! 		if type(prog) == type(''):
  			prog = re.compile(string.lower(prog))
  		if self.selection:
--- 463,467 ----
  	def search(self, prog):
  		import re, string
! 		if type(prog) is type(''):
  			prog = re.compile(string.lower(prog))
  		if self.selection:
***************
*** 552,556 ****
  					self.fontcache[key] = handle
  		self.fontkey = fontkey
! 		if self.fonthandle <> handle:
  			self.fonthandle = handle
  			self.fontinfo = handle.getfontinfo()
--- 552,556 ----
  					self.fontcache[key] = handle
  		self.fontkey = fontkey
! 		if self.fonthandle != handle:
  			self.fonthandle = handle
  			self.fontinfo = handle.getfontinfo()
***************
*** 583,587 ****
  		oldhandle = self.fonthandle
  		GLFontCache.setfont(fontkey)
! 		if self.fonthandle <> oldhandle:
  			handle.setfont()
  
--- 583,587 ----
  		oldhandle = self.fonthandle
  		GLFontCache.setfont(fontkey)
! 		if self.fonthandle != oldhandle:
  			handle.setfont()
  
***************
*** 613,617 ****
  		gl.winset(self.wid)
  		width = gl.getsize()[1]
! 		if width <> self.width:
  			setdocsize = 1
  			self.width = width
--- 613,617 ----
  		gl.winset(self.wid)
  		width = gl.getsize()[1]
! 		if width != self.width:
  			setdocsize = 1
  			self.width = width

Index: grep.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/grep.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** grep.py	1997/10/22 20:44:58	1.7
--- grep.py	2000/12/12 23:11:41	1.8
***************
*** 74,78 ****
  			prefix = ' ' * len(prefix)
  			for c in line:
! 				if c <> '\t': c = ' '
  				prefix = prefix + c
  		if start == end: prefix = prefix + '\\'
--- 74,78 ----
  			prefix = ' ' * len(prefix)
  			for c in line:
! 				if c != '\t': c = ' '
  				prefix = prefix + c
  		if start == end: prefix = prefix + '\\'

Index: packmail.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/packmail.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** packmail.py	1998/04/28 16:03:03	1.7
--- packmail.py	2000/12/12 23:11:41	1.8
***************
*** 26,30 ****
  		line = fp.readline()
  		if not line: break
! 		if line[-1:] <> '\n':
  			line = line + '\n'
  		outfp.write('X' + line)
--- 26,30 ----
  		line = fp.readline()
  		if not line: break
! 		if line[-1:] != '\n':
  			line = line + '\n'
  		outfp.write('X' + line)

Index: tb.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/tb.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** tb.py	1997/09/29 23:21:47	1.7
--- tb.py	2000/12/12 23:11:41	1.8
***************
*** 24,28 ****
  	tb = tblist[ptr]
  	while 1:
! 		if tb <> tblist[ptr]:
  			tb = tblist[ptr]
  			print `ptr` + ':',
--- 24,28 ----
  	tb = tblist[ptr]
  	while 1:
! 		if tb != tblist[ptr]:
  			tb = tblist[ptr]
  			print `ptr` + ':',
***************
*** 77,85 ****
  		t, v = sys.exc_info()[:2]
  		print '*** Exception:',
! 		if type(t) == type(''):
  			print t,
  		else:
  			print t.__name__,
! 		if v <> None:
  			print ':', v,
  		print
--- 77,85 ----
  		t, v = sys.exc_info()[:2]
  		print '*** Exception:',
! 		if type(t) is type(''):
  			print t,
  		else:
  			print t.__name__,
! 		if v is not None:
  			print ':', v,
  		print
***************
*** 128,149 ****
  
  def printobject(v, maxlevel):
! 	if v == None:
  		print 'None',
  	elif type(v) in (type(0), type(0.0)):
  		print v,
! 	elif type(v) == type(''):
  		if len(v) > 20:
  			print `v[:17] + '...'`,
  		else:
  			print `v`,
! 	elif type(v) == type(()):
  		print '(',
  		printlist(v, maxlevel)
  		print ')',
! 	elif type(v) == type([]):
  		print '[',
  		printlist(v, maxlevel)
  		print ']',
! 	elif type(v) == type({}):
  		print '{',
  		printdict(v, maxlevel)
--- 128,149 ----
  
  def printobject(v, maxlevel):
! 	if v is None:
  		print 'None',
  	elif type(v) in (type(0), type(0.0)):
  		print v,
! 	elif type(v) is type(''):
  		if len(v) > 20:
  			print `v[:17] + '...'`,
  		else:
  			print `v`,
! 	elif type(v) is type(()):
  		print '(',
  		printlist(v, maxlevel)
  		print ')',
! 	elif type(v) is type([]):
  		print '[',
  		printlist(v, maxlevel)
  		print ']',
! 	elif type(v) is type({}):
  		print '{',
  		printdict(v, maxlevel)

Index: zmod.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/lib-old/zmod.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** zmod.py	1998/11/02 15:38:51	1.1
--- zmod.py	2000/12/12 23:11:41	1.2
***************
*** 83,87 ****
  
  def rj(s, width):
! 	if type(s) <> type(''): s = `s`
  	n = len(s)
  	if n >= width: return s
--- 83,87 ----
  
  def rj(s, width):
! 	if type(s) is not type(''): s = `s`
  	n = len(s)
  	if n >= width: return s
***************
*** 89,93 ****
  
  def lj(s, width):
! 	if type(s) <> type(''): s = `s`
  	n = len(s)
  	if n >= width: return s
--- 89,93 ----
  
  def lj(s, width):
! 	if type(s) is not type(''): s = `s`
  	n = len(s)
  	if n >= width: return s