[Python-checkins] python/dist/src/Demo/scripts eqfix.py, 1.7, 1.8 from.py, 1.8, 1.9 ftpstats.py, 1.3, 1.4 lpwatch.py, 1.7, 1.8 markov.py, 1.3, 1.4 mboxconvert.py, 1.4, 1.5 mkrcs.py, 1.4, 1.5 mpzpi.py, 1.4, 1.5 newslist.py, 1.10, 1.11 pp.py, 1.5, 1.6

doerwalter at users.sourceforge.net doerwalter at users.sourceforge.net
Thu Feb 12 12:35:36 EST 2004


Update of /cvsroot/python/python/dist/src/Demo/scripts
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21620/Demo/scripts
Modified Files:
	eqfix.py from.py ftpstats.py lpwatch.py markov.py 
	mboxconvert.py mkrcs.py mpzpi.py newslist.py pp.py 
Log Message:
Replace backticks with repr() or "%r"
>From SF patch #852334.

Index: eqfix.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/scripts/eqfix.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** eqfix.py	27 Nov 1996 19:46:46 -0000	1.7
--- eqfix.py	12 Feb 2004 17:35:02 -0000	1.8
***************
*** 59,68 ****
 
 def recursedown(dirname):
! 	dbg('recursedown(' + `dirname` + ')\n')
 	bad = 0
 	try:
 		names = os.listdir(dirname)
 	except os.error, msg:
! 		err(dirname + ': cannot list directory: ' + `msg` + '\n')
 		return 1
 	names.sort()
--- 59,68 ----
 
 def recursedown(dirname):
! 	dbg('recursedown(%r)\n' % (dirname,))
 	bad = 0
 	try:
 		names = os.listdir(dirname)
 	except os.error, msg:
! 		err('%s: cannot list directory: %r\n' % (dirname, msg))
 		return 1
 	names.sort()
***************
*** 81,89 ****
 
 def fix(filename):
! ##	dbg('fix(' + `filename` + ')\n')
 	try:
 		f = open(filename, 'r')
 	except IOError, msg:
! 		err(filename + ': cannot open: ' + `msg` + '\n')
 		return 1
 	head, tail = os.path.split(filename)
--- 81,89 ----
 
 def fix(filename):
! ##	dbg('fix(%r)\n' % (dirname,))
 	try:
 		f = open(filename, 'r')
 	except IOError, msg:
! 		err('%s: cannot open: %r\n' % (filename, msg))
 		return 1
 	head, tail = os.path.split(filename)
***************
*** 123,128 ****
 				except IOError, msg:
 					f.close()
! 					err(tempname+': cannot create: '+\
! 					 `msg`+'\n')
 					return 1
 				f.seek(0)
--- 123,127 ----
 				except IOError, msg:
 					f.close()
! 					err('%s: cannot create: %r\n' % (tempname, msg))
 					return 1
 				f.seek(0)
***************
*** 130,134 ****
 				rep(filename + ':\n')
 				continue # restart from the beginning
! 			rep(`lineno` + '\n')
 			rep('< ' + line)
 			rep('> ' + newline)
--- 129,133 ----
 				rep(filename + ':\n')
 				continue # restart from the beginning
! 			rep(repr(lineno) + '\n')
 			rep('< ' + line)
 			rep('> ' + newline)
***************
*** 147,161 ****
 		os.chmod(tempname, statbuf[ST_MODE] & 07777)
 	except os.error, msg:
! 		err(tempname + ': warning: chmod failed (' + `msg` + ')\n')
 	# Then make a backup of the original file as filename~
 	try:
 		os.rename(filename, filename + '~')
 	except os.error, msg:
! 		err(filename + ': warning: backup failed (' + `msg` + ')\n')
 	# Now move the temp file to the original file
 	try:
 		os.rename(tempname, filename)
 	except os.error, msg:
! 		err(filename + ': rename failed (' + `msg` + ')\n')
 		return 1
 	# Return succes
--- 146,160 ----
 		os.chmod(tempname, statbuf[ST_MODE] & 07777)
 	except os.error, msg:
! 		err('%s: warning: chmod failed (%r)\n' % (tempname, msg))
 	# Then make a backup of the original file as filename~
 	try:
 		os.rename(filename, filename + '~')
 	except os.error, msg:
! 		err('%s: warning: backup failed (%r)\n' % (filename, msg))
 	# Now move the temp file to the original file
 	try:
 		os.rename(tempname, filename)
 	except os.error, msg:
! 		err('%s: rename failed (%r)\n' % (filename, msg))
 		return 1
 	# Return succes
Index: from.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/scripts/from.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** from.py	20 Feb 2001 16:21:35 -0000	1.8
--- from.py	12 Feb 2004 17:35:03 -0000	1.9
***************
*** 32,35 ****
 break
 if line.startswith('Subject: '):
! print `line[9:-1]`,
 print
--- 32,35 ----
 break
 if line.startswith('Subject: '):
! print repr(line[9:-1]),
 print
Index: ftpstats.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/scripts/ftpstats.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ftpstats.py	14 Sep 1998 16:44:00 -0000	1.3
--- ftpstats.py	12 Feb 2004 17:35:03 -0000	1.4
***************
*** 61,65 ****
 				continue
 			if prog.match(line) < 0:
! 				print 'Bad line', lineno, ':', `line`
 				continue
 			items = prog.group(1, 2, 3, 4, 5, 6)
--- 61,65 ----
 				continue
 			if prog.match(line) < 0:
! 				print 'Bad line', lineno, ':', repr(line)
 				continue
 			items = prog.group(1, 2, 3, 4, 5, 6)
Index: lpwatch.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/scripts/lpwatch.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** lpwatch.py	27 Nov 1996 19:46:53 -0000	1.7
--- lpwatch.py	12 Feb 2004 17:35:03 -0000	1.8
***************
*** 84,105 ****
 	#
 	if totaljobs:
! 		line = `(totalbytes+1023)/1024` + ' K'
 		if totaljobs <> len(users):
! 			line = line + ' (' + `totaljobs` + ' jobs)'
 		if len(users) == 1:
! 			line = line + ' for ' + users.keys()[0]
 		else:
! 			line = line + ' for ' + `len(users)` + ' users'
 			if userseen:
 				if aheadjobs == 0:
! 				 line = line + ' (' + thisuser + ' first)'
 				else:
! 				 line = line + ' (' + `(aheadbytes+1023)/1024`
! 				 line = line + ' K before ' + thisuser + ')'
 		lines.append(line)
 	#
 	sts = pipe.close()
 	if sts:
! 		lines.append('lpq exit status ' + `sts`)
 	return string.joinfields(lines, ': ')
 
--- 84,105 ----
 	#
 	if totaljobs:
! 		line = '%d K' % ((totalbytes+1023)/1024)
 		if totaljobs <> len(users):
! 			line = line + ' (%d jobs)' % totaljobs
 		if len(users) == 1:
! 			line = line + ' for %s' % (users.keys()[0],)
 		else:
! 			line = line + ' for %d users' % len(users)
 			if userseen:
 				if aheadjobs == 0:
! 					line = line + ' (%s first)' % thisuser
 				else:
! 					line = line + ' (%d K before %s)' % (
! 					 (aheadbytes+1023)/1024, thisuser)
 		lines.append(line)
 	#
 	sts = pipe.close()
 	if sts:
! 		lines.append('lpq exit status %r' % (sts,))
 	return string.joinfields(lines, ': ')
 
Index: markov.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/scripts/markov.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** markov.py	20 May 1998 17:11:46 -0000	1.3
--- markov.py	12 Feb 2004 17:35:03 -0000	1.4
***************
*** 90,95 ****
 		for key in m.trans.keys():
 			if key is None or len(key) < histsize:
! 				print `key`, m.trans[key]
! 		if histsize == 0: print `''`, m.trans['']
 		print
 	while 1:
--- 90,95 ----
 		for key in m.trans.keys():
 			if key is None or len(key) < histsize:
! 				print repr(key), m.trans[key]
! 		if histsize == 0: print repr(''), m.trans['']
 		print
 	while 1:
Index: mboxconvert.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/scripts/mboxconvert.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** mboxconvert.py	27 Nov 1996 19:46:57 -0000	1.4
--- mboxconvert.py	12 Feb 2004 17:35:03 -0000	1.5
***************
*** 74,78 ****
 		else:
 			sys.stderr.write(
! 				'Bad line in MMFD mailbox: %s\n' % `line`)
 	return sts
 
--- 74,78 ----
 		else:
 			sys.stderr.write(
! 				'Bad line in MMFD mailbox: %r\n' % (line,))
 	return sts
 
***************
*** 90,94 ****
 	else:
 		sys.stderr.write(
! 			'Unparseable date: %s\n' % `m.getheader('Date')`)
 		t = os.fstat(f.fileno())[stat.ST_MTIME]
 	print 'From', email, time.ctime(t)
--- 90,94 ----
 	else:
 		sys.stderr.write(
! 			'Unparseable date: %r\n' % (m.getheader('Date'),))
 		t = os.fstat(f.fileno())[stat.ST_MTIME]
 	print 'From', email, time.ctime(t)
Index: mkrcs.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/scripts/mkrcs.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** mkrcs.py	27 Nov 1996 19:46:59 -0000	1.4
--- mkrcs.py	12 Feb 2004 17:35:03 -0000	1.5
***************
*** 13,23 ****
 	rcs = 'RCS'
 	if os.path.islink(rcs):
! 		print `rcs`, 'is a symlink to', `os.readlink(rcs)`
 		return
 	if os.path.isdir(rcs):
! 		print `rcs`, 'is an ordinary directory'
 		return
 	if os.path.exists(rcs):
! 		print `rcs`, 'is a file?!?!'
 		return
 	#
--- 13,23 ----
 	rcs = 'RCS'
 	if os.path.islink(rcs):
! 		print '%r is a symlink to %r' % (rcs, os.readlink(rcs))
 		return
 	if os.path.isdir(rcs):
! 		print '%r is an ordinary directory' % (rcs,)
 		return
 	if os.path.exists(rcs):
! 		print '%r is a file?!?!' % (rcs,)
 		return
 	#
***************
*** 30,53 ****
 	# Ergo:
 	# (3) join(up, down) is the current directory
! 	#print 'p =', `p`
 	while not os.path.isdir(os.path.join(p, rcstree)):
 		head, tail = os.path.split(p)
! 		#print 'head =', `head`, '; tail =', `tail`
 		if not tail:
! 			print 'Sorry, no ancestor dir contains', `rcstree`
 			return
 		p = head
 		up = os.path.join(os.pardir, up)
 		down = os.path.join(tail, down)
! 		#print 'p =', `p`, '; up =', `up`, '; down =', `down`
 	there = os.path.join(up, rcstree)
 	there = os.path.join(there, down)
 	there = os.path.join(there, rcs)
 	if os.path.isdir(there):
! 		print `there`, 'already exists'
 	else:
! 		print 'making', `there`
 		makedirs(there)
! 	print 'making symlink', `rcs`, '->', `there`
 	os.symlink(there, rcs)
 
--- 30,53 ----
 	# Ergo:
 	# (3) join(up, down) is the current directory
! 	#print 'p =', repr(p)
 	while not os.path.isdir(os.path.join(p, rcstree)):
 		head, tail = os.path.split(p)
! 		#print 'head = %r; tail = %r' % (head, tail)
 		if not tail:
! 			print 'Sorry, no ancestor dir contains %r' % (rcstree,)
 			return
 		p = head
 		up = os.path.join(os.pardir, up)
 		down = os.path.join(tail, down)
! 		#print 'p = %r; up = %r; down = %r' % (p, up, down)
 	there = os.path.join(up, rcstree)
 	there = os.path.join(there, down)
 	there = os.path.join(there, rcs)
 	if os.path.isdir(there):
! 		print '%r already exists' % (there, )
 	else:
! 		print 'making %r' % (there,)
 		makedirs(there)
! 	print 'making symlink %r -> %r' % (rcs, there)
 	os.symlink(there, rcs)
 
Index: mpzpi.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/scripts/mpzpi.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** mpzpi.py	10 Dec 2003 15:22:23 -0000	1.4
--- mpzpi.py	12 Feb 2004 17:35:03 -0000	1.5
***************
*** 28,32 ****
 	# Use write() to avoid spaces between the digits
 	# Use int(d) to avoid a trailing L after each digit
! 	sys.stdout.write(`int(d)`)
 	# Flush so the output is seen immediately
 	sys.stdout.flush()
--- 28,32 ----
 	# Use write() to avoid spaces between the digits
 	# Use int(d) to avoid a trailing L after each digit
! 	sys.stdout.write(repr(int(d)))
 	# Flush so the output is seen immediately
 	sys.stdout.flush()
Index: newslist.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/scripts/newslist.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** newslist.py	14 Sep 1998 16:44:01 -0000	1.10
--- newslist.py	12 Feb 2004 17:35:03 -0000	1.11
***************
*** 305,309 ****
 print 'Getting list of new groups since start of '+treedate+'...',
 info = server.newgroups(treedate,'000001')[1]
! print 'got '+`len(info)`+'.'
 print 'Processing...',
 groups = []
--- 305,309 ----
 print 'Getting list of new groups since start of '+treedate+'...',
 info = server.newgroups(treedate,'000001')[1]
! print 'got %d.' % len(info)
 print 'Processing...',
 groups = []
Index: pp.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/scripts/pp.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** pp.py	9 Aug 2002 16:38:32 -0000	1.5
--- pp.py	12 Feb 2004 17:35:03 -0000	1.6
***************
*** 126,130 ****
 if DFLAG:
 	import pdb
! 	pdb.run('execfile(' + `tfn` + ')')
 else:
 	execfile(tfn)
--- 126,130 ----
 if DFLAG:
 	import pdb
! 	pdb.run('execfile(%r)' % (tfn,))
 else:
 	execfile(tfn)


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /