parent
ecfeb7f095
commit
70a6b49821
|
@ -117,15 +117,15 @@ class Complex:
|
|||
|
||||
def __repr__(self):
|
||||
if not self.im:
|
||||
return 'Complex(%s)' % `self.re`
|
||||
return 'Complex(%r)' % (self.re,)
|
||||
else:
|
||||
return 'Complex(%s, %s)' % (`self.re`, `self.im`)
|
||||
return 'Complex(%r, %r)' % (self.re, self.im)
|
||||
|
||||
def __str__(self):
|
||||
if not self.im:
|
||||
return `self.re`
|
||||
return repr(self.re)
|
||||
else:
|
||||
return 'Complex(%s, %s)' % (`self.re`, `self.im`)
|
||||
return 'Complex(%r, %r)' % (self.re, self.im)
|
||||
|
||||
def __neg__(self):
|
||||
return Complex(-self.re, -self.im)
|
||||
|
|
|
@ -86,7 +86,7 @@ _DI400Y = _days_before_year( 400 ) # number of days in 400 years
|
|||
|
||||
def _num2date( n ): # return date with ordinal n
|
||||
if type(n) not in _INT_TYPES:
|
||||
raise TypeError, 'argument must be integer: ' + `type(n)`
|
||||
raise TypeError, 'argument must be integer: %r' % type(n)
|
||||
|
||||
ans = Date(1,1,1) # arguments irrelevant; just getting a Date obj
|
||||
del ans.ord, ans.month, ans.day, ans.year # un-initialize it
|
||||
|
@ -120,10 +120,10 @@ def _num2day( n ): # return weekday name of day with ordinal n
|
|||
class Date:
|
||||
def __init__( self, month, day, year ):
|
||||
if not 1 <= month <= 12:
|
||||
raise ValueError, 'month must be in 1..12: ' + `month`
|
||||
raise ValueError, 'month must be in 1..12: %r' % (month,)
|
||||
dim = _days_in_month( month, year )
|
||||
if not 1 <= day <= dim:
|
||||
raise ValueError, 'day must be in 1..' + `dim` + ': ' + `day`
|
||||
raise ValueError, 'day must be in 1..%r: %r' % (dim, day)
|
||||
self.month, self.day, self.year = month, day, year
|
||||
self.ord = _date2num( self )
|
||||
|
||||
|
@ -142,15 +142,16 @@ class Date:
|
|||
|
||||
# print as, e.g., Mon 16 Aug 1993
|
||||
def __repr__( self ):
|
||||
return '%.3s %2d %.3s ' % (
|
||||
return '%.3s %2d %.3s %r' % (
|
||||
self.weekday(),
|
||||
self.day,
|
||||
_MONTH_NAMES[self.month-1] ) + `self.year`
|
||||
_MONTH_NAMES[self.month-1],
|
||||
self.year)
|
||||
|
||||
# Python 1.1 coerces neither int+date nor date+int
|
||||
def __add__( self, n ):
|
||||
if type(n) not in _INT_TYPES:
|
||||
raise TypeError, 'can\'t add ' + `type(n)` + ' to date'
|
||||
raise TypeError, 'can\'t add %r to date' % type(n)
|
||||
return _num2date( self.ord + n )
|
||||
__radd__ = __add__ # handle int+date
|
||||
|
||||
|
@ -177,7 +178,7 @@ DateTestError = 'DateTestError'
|
|||
def test( firstyear, lastyear ):
|
||||
a = Date(9,30,1913)
|
||||
b = Date(9,30,1914)
|
||||
if `a` != 'Tue 30 Sep 1913':
|
||||
if repr(a) != 'Tue 30 Sep 1913':
|
||||
raise DateTestError, '__repr__ failure'
|
||||
if (not a < b) or a == b or a > b or b != b:
|
||||
raise DateTestError, '__cmp__ failure'
|
||||
|
|
|
@ -13,7 +13,7 @@ class Dbm:
|
|||
def __repr__(self):
|
||||
s = ''
|
||||
for key in self.keys():
|
||||
t = `key` + ': ' + `self[key]`
|
||||
t = repr(key) + ': ' + repr(self[key])
|
||||
if s: t = ', ' + t
|
||||
s = s + t
|
||||
return '{' + s + '}'
|
||||
|
@ -22,13 +22,13 @@ class Dbm:
|
|||
return len(self.db)
|
||||
|
||||
def __getitem__(self, key):
|
||||
return eval(self.db[`key`])
|
||||
return eval(self.db[repr(key)])
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
self.db[`key`] = `value`
|
||||
self.db[repr(key)] = repr(value)
|
||||
|
||||
def __delitem__(self, key):
|
||||
del self.db[`key`]
|
||||
del self.db[repr(key)]
|
||||
|
||||
def keys(self):
|
||||
res = []
|
||||
|
@ -37,7 +37,7 @@ class Dbm:
|
|||
return res
|
||||
|
||||
def has_key(self, key):
|
||||
return self.db.has_key(`key`)
|
||||
return self.db.has_key(repr(key))
|
||||
|
||||
|
||||
def test():
|
||||
|
|
|
@ -34,9 +34,9 @@ class Range:
|
|||
self.step = step
|
||||
self.len = max(0, int((self.stop - self.start) / self.step))
|
||||
|
||||
# implement `x` and is also used by print x
|
||||
# implement repr(x) and is also used by print x
|
||||
def __repr__(self):
|
||||
return 'range' + `self.start, self.stop, self.step`
|
||||
return 'range(%r, %r, %r)' % (self.start, self.stop, self.step)
|
||||
|
||||
# implement len(x)
|
||||
def __len__(self):
|
||||
|
|
|
@ -20,7 +20,7 @@ def _compute_len(param):
|
|||
mant, l = math.frexp(float(param))
|
||||
bitmask = 1L << l
|
||||
if bitmask <= param:
|
||||
raise 'FATAL', '(param, l) = ' + `param, l`
|
||||
raise 'FATAL', '(param, l) = %r' % ((param, l),)
|
||||
while l:
|
||||
bitmask = bitmask >> 1
|
||||
if param & bitmask:
|
||||
|
@ -167,10 +167,10 @@ class BitVec:
|
|||
|
||||
def __repr__(self):
|
||||
##rprt('<bitvec class instance object>.' + '__repr__()\n')
|
||||
return 'bitvec' + `self._data, self._len`
|
||||
return 'bitvec(%r, %r)' % (self._data, self._len)
|
||||
|
||||
def __cmp__(self, other, *rest):
|
||||
#rprt(`self`+'.__cmp__'+`(other, ) + rest`+'\n')
|
||||
#rprt('%r.__cmp__%r\n' % (self, (other,) + rest))
|
||||
if type(other) != type(self):
|
||||
other = apply(bitvec, (other, ) + rest)
|
||||
#expensive solution... recursive binary, with slicing
|
||||
|
@ -193,16 +193,16 @@ class BitVec:
|
|||
|
||||
|
||||
def __len__(self):
|
||||
#rprt(`self`+'.__len__()\n')
|
||||
#rprt('%r.__len__()\n' % (self,))
|
||||
return self._len
|
||||
|
||||
def __getitem__(self, key):
|
||||
#rprt(`self`+'.__getitem__('+`key`+')\n')
|
||||
#rprt('%r.__getitem__(%r)\n' % (self, key))
|
||||
key = _check_key(self._len, key)
|
||||
return self._data & (1L << key) != 0
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
#rprt(`self`+'.__setitem__'+`key, value`+'\n')
|
||||
#rprt('%r.__setitem__(%r, %r)\n' % (self, key, value))
|
||||
key = _check_key(self._len, key)
|
||||
#_check_value(value)
|
||||
if value:
|
||||
|
@ -211,14 +211,14 @@ class BitVec:
|
|||
self._data = self._data & ~(1L << key)
|
||||
|
||||
def __delitem__(self, key):
|
||||
#rprt(`self`+'.__delitem__('+`key`+')\n')
|
||||
#rprt('%r.__delitem__(%r)\n' % (self, key))
|
||||
key = _check_key(self._len, key)
|
||||
#el cheapo solution...
|
||||
self._data = self[:key]._data | self[key+1:]._data >> key
|
||||
self._len = self._len - 1
|
||||
|
||||
def __getslice__(self, i, j):
|
||||
#rprt(`self`+'.__getslice__'+`i, j`+'\n')
|
||||
#rprt('%r.__getslice__(%r, %r)\n' % (self, i, j))
|
||||
i, j = _check_slice(self._len, i, j)
|
||||
if i >= j:
|
||||
return BitVec(0L, 0)
|
||||
|
@ -234,7 +234,7 @@ class BitVec:
|
|||
return BitVec(ndata, nlength)
|
||||
|
||||
def __setslice__(self, i, j, sequence, *rest):
|
||||
#rprt(`self`+'.__setslice__'+`(i, j, sequence) + rest`+'\n')
|
||||
#rprt('%s.__setslice__%r\n' % (self, (i, j, sequence) + rest))
|
||||
i, j = _check_slice(self._len, i, j)
|
||||
if type(sequence) != type(self):
|
||||
sequence = apply(bitvec, (sequence, ) + rest)
|
||||
|
@ -247,7 +247,7 @@ class BitVec:
|
|||
self._len = self._len - j + i + sequence._len
|
||||
|
||||
def __delslice__(self, i, j):
|
||||
#rprt(`self`+'.__delslice__'+`i, j`+'\n')
|
||||
#rprt('%r.__delslice__(%r, %r)\n' % (self, i, j))
|
||||
i, j = _check_slice(self._len, i, j)
|
||||
if i == 0 and j == self._len:
|
||||
self._data, self._len = 0L, 0
|
||||
|
@ -256,13 +256,13 @@ class BitVec:
|
|||
self._len = self._len - j + i
|
||||
|
||||
def __add__(self, other):
|
||||
#rprt(`self`+'.__add__('+`other`+')\n')
|
||||
#rprt('%r.__add__(%r)\n' % (self, other))
|
||||
retval = self.copy()
|
||||
retval[self._len:self._len] = other
|
||||
return retval
|
||||
|
||||
def __mul__(self, multiplier):
|
||||
#rprt(`self`+'.__mul__('+`multiplier`+')\n')
|
||||
#rprt('%r.__mul__(%r)\n' % (self, multiplier))
|
||||
if type(multiplier) != type(0):
|
||||
raise TypeError, 'sequence subscript not int'
|
||||
if multiplier <= 0:
|
||||
|
@ -281,7 +281,7 @@ class BitVec:
|
|||
return retval
|
||||
|
||||
def __and__(self, otherseq, *rest):
|
||||
#rprt(`self`+'.__and__'+`(otherseq, ) + rest`+'\n')
|
||||
#rprt('%r.__and__%r\n' % (self, (otherseq,) + rest))
|
||||
if type(otherseq) != type(self):
|
||||
otherseq = apply(bitvec, (otherseq, ) + rest)
|
||||
#sequence is now of our own type
|
||||
|
@ -290,7 +290,7 @@ class BitVec:
|
|||
|
||||
|
||||
def __xor__(self, otherseq, *rest):
|
||||
#rprt(`self`+'.__xor__'+`(otherseq, ) + rest`+'\n')
|
||||
#rprt('%r.__xor__%r\n' % (self, (otherseq,) + rest))
|
||||
if type(otherseq) != type(self):
|
||||
otherseq = apply(bitvec, (otherseq, ) + rest)
|
||||
#sequence is now of our own type
|
||||
|
@ -299,7 +299,7 @@ class BitVec:
|
|||
|
||||
|
||||
def __or__(self, otherseq, *rest):
|
||||
#rprt(`self`+'.__or__'+`(otherseq, ) + rest`+'\n')
|
||||
#rprt('%r.__or__%r\n' % (self, (otherseq,) + rest))
|
||||
if type(otherseq) != type(self):
|
||||
otherseq = apply(bitvec, (otherseq, ) + rest)
|
||||
#sequence is now of our own type
|
||||
|
@ -308,13 +308,13 @@ class BitVec:
|
|||
|
||||
|
||||
def __invert__(self):
|
||||
#rprt(`self`+'.__invert__()\n')
|
||||
#rprt('%r.__invert__()\n' % (self,))
|
||||
return BitVec(~self._data & ((1L << self._len) - 1), \
|
||||
self._len)
|
||||
|
||||
def __coerce__(self, otherseq, *rest):
|
||||
#needed for *some* of the arithmetic operations
|
||||
#rprt(`self`+'.__coerce__'+`(otherseq, ) + rest`+'\n')
|
||||
#rprt('%r.__coerce__%r\n' % (self, (otherseq,) + rest))
|
||||
if type(otherseq) != type(self):
|
||||
otherseq = apply(bitvec, (otherseq, ) + rest)
|
||||
return self, otherseq
|
||||
|
|
|
@ -107,9 +107,9 @@ class EnumInstance:
|
|||
return self.__value
|
||||
|
||||
def __repr__(self):
|
||||
return "EnumInstance(%s, %s, %s)" % (`self.__classname`,
|
||||
`self.__enumname`,
|
||||
`self.__value`)
|
||||
return "EnumInstance(%r, %r, %r)" % (self.__classname,
|
||||
self.__enumname,
|
||||
self.__value)
|
||||
|
||||
def __str__(self):
|
||||
return "%s.%s" % (self.__classname, self.__enumname)
|
||||
|
|
|
@ -98,7 +98,7 @@ def _test():
|
|||
def __init__(self, *args):
|
||||
print "__init__, args =", args
|
||||
def m1(self, x):
|
||||
print "m1(x=%s)" %`x`
|
||||
print "m1(x=%r)" % (x,)
|
||||
print C
|
||||
x = C()
|
||||
print x
|
||||
|
|
|
@ -117,7 +117,7 @@ def _test():
|
|||
def m2(self, y): return self.x + y
|
||||
__trace_output__ = sys.stdout
|
||||
class D(C):
|
||||
def m2(self, y): print "D.m2(%s)" % `y`; return C.m2(self, y)
|
||||
def m2(self, y): print "D.m2(%r)" % (y,); return C.m2(self, y)
|
||||
__trace_output__ = None
|
||||
x = C(4321)
|
||||
print x
|
||||
|
|
|
@ -97,7 +97,7 @@ def _test():
|
|||
|
||||
print Color.red
|
||||
|
||||
print `Color.red`
|
||||
print repr(Color.red)
|
||||
print Color.red == Color.red
|
||||
print Color.red == Color.blue
|
||||
print Color.red == 1
|
||||
|
@ -139,7 +139,7 @@ def _test2():
|
|||
|
||||
print Color.red
|
||||
|
||||
print `Color.red`
|
||||
print repr(Color.red)
|
||||
print Color.red == Color.red
|
||||
print Color.red == Color.blue
|
||||
print Color.red == 1
|
||||
|
|
|
@ -188,7 +188,7 @@ def test():
|
|||
if callable(attr):
|
||||
print apply(attr, tuple(sys.argv[2:]))
|
||||
else:
|
||||
print `attr`
|
||||
print repr(attr)
|
||||
else:
|
||||
print "%s: no such attribute" % what
|
||||
sys.exit(2)
|
||||
|
|
|
@ -139,7 +139,7 @@ class SecureClient(Client, Security):
|
|||
line = self._rf.readline()
|
||||
challenge = string.atoi(string.strip(line))
|
||||
response = self._encode_challenge(challenge)
|
||||
line = `long(response)`
|
||||
line = repr(long(response))
|
||||
if line[-1] in 'Ll': line = line[:-1]
|
||||
self._wf.write(line + '\n')
|
||||
self._wf.flush()
|
||||
|
|
|
@ -55,7 +55,7 @@ class CommandFrameWork:
|
|||
try:
|
||||
method = getattr(self, mname)
|
||||
except AttributeError:
|
||||
return self.usage("command %s unknown" % `cmd`)
|
||||
return self.usage("command %r unknown" % (cmd,))
|
||||
try:
|
||||
flags = getattr(self, fname)
|
||||
except AttributeError:
|
||||
|
@ -75,7 +75,7 @@ class CommandFrameWork:
|
|||
print "-"*40
|
||||
print "Options:"
|
||||
for o, a in opts:
|
||||
print 'option', o, 'value', `a`
|
||||
print 'option', o, 'value', repr(a)
|
||||
print "-"*40
|
||||
|
||||
def ready(self):
|
||||
|
@ -137,7 +137,7 @@ def test():
|
|||
for t in tests:
|
||||
print '-'*10, t, '-'*10
|
||||
sts = x.run(t)
|
||||
print "Exit status:", `sts`
|
||||
print "Exit status:", repr(sts)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -49,7 +49,7 @@ def askint(prompt, default):
|
|||
|
||||
def compare(local, remote, mode):
|
||||
print
|
||||
print "PWD =", `os.getcwd()`
|
||||
print "PWD =", repr(os.getcwd())
|
||||
sums_id = remote._send('sumlist')
|
||||
subdirs_id = remote._send('listsubdirs')
|
||||
remote._flush()
|
||||
|
@ -64,13 +64,13 @@ def compare(local, remote, mode):
|
|||
for name, rsum in sums:
|
||||
rsumdict[name] = rsum
|
||||
if not lsumdict.has_key(name):
|
||||
print `name`, "only remote"
|
||||
print repr(name), "only remote"
|
||||
if 'r' in mode and 'c' in mode:
|
||||
recvfile(local, remote, name)
|
||||
else:
|
||||
lsum = lsumdict[name]
|
||||
if lsum != rsum:
|
||||
print `name`,
|
||||
print repr(name),
|
||||
rmtime = remote.mtime(name)
|
||||
lmtime = local.mtime(name)
|
||||
if rmtime > lmtime:
|
||||
|
@ -86,7 +86,7 @@ def compare(local, remote, mode):
|
|||
print
|
||||
for name in lsumdict.keys():
|
||||
if not rsumdict.keys():
|
||||
print `name`, "only locally",
|
||||
print repr(name), "only locally",
|
||||
fl()
|
||||
if 'w' in mode and 'c' in mode:
|
||||
sendfile(local, remote, name)
|
||||
|
@ -160,7 +160,7 @@ def recvfile(local, remote, name):
|
|||
return rv
|
||||
finally:
|
||||
if not ok:
|
||||
print "*** recvfile of %s failed, deleting" % `name`
|
||||
print "*** recvfile of %r failed, deleting" % (name,)
|
||||
local.delete(name)
|
||||
|
||||
def recvfile_real(local, remote, name):
|
||||
|
|
|
@ -114,7 +114,7 @@ class Lock:
|
|||
self.delay = delay
|
||||
self.lockdir = None
|
||||
self.lockfile = None
|
||||
pid = `os.getpid()`
|
||||
pid = repr(os.getpid())
|
||||
self.cvslck = self.join(CVSLCK)
|
||||
self.cvsrfl = self.join(CVSRFL + pid)
|
||||
self.cvswfl = self.join(CVSWFL + pid)
|
||||
|
|
|
@ -232,7 +232,7 @@ class RCS:
|
|||
"""
|
||||
name, rev = self._unmangle(name_rev)
|
||||
if not self.isvalid(name):
|
||||
raise os.error, 'not an rcs file %s' % `name`
|
||||
raise os.error, 'not an rcs file %r' % (name,)
|
||||
return name, rev
|
||||
|
||||
# --- Internal methods ---
|
||||
|
@ -252,7 +252,7 @@ class RCS:
|
|||
namev = self.rcsname(name)
|
||||
if rev:
|
||||
cmd = cmd + ' ' + rflag + rev
|
||||
return os.popen("%s %s" % (cmd, `namev`))
|
||||
return os.popen("%s %r" % (cmd, namev))
|
||||
|
||||
def _unmangle(self, name_rev):
|
||||
"""INTERNAL: Normalize NAME_REV argument to (NAME, REV) tuple.
|
||||
|
|
|
@ -134,11 +134,11 @@ class SecureServer(Server, Security):
|
|||
response = string.atol(string.strip(response))
|
||||
except string.atol_error:
|
||||
if self._verbose > 0:
|
||||
print "Invalid response syntax", `response`
|
||||
print "Invalid response syntax", repr(response)
|
||||
return 0
|
||||
if not self._compare_challenge_response(challenge, response):
|
||||
if self._verbose > 0:
|
||||
print "Invalid response value", `response`
|
||||
print "Invalid response value", repr(response)
|
||||
return 0
|
||||
if self._verbose > 1:
|
||||
print "Response matches challenge. Go ahead!"
|
||||
|
|
|
@ -18,5 +18,5 @@ def TSTOP(*label):
|
|||
[u, s, r] = tt
|
||||
msg = ''
|
||||
for x in label: msg = msg + (x + ' ')
|
||||
msg = msg + `u` + ' user, ' + `s` + ' sys, ' + `r` + ' real\n'
|
||||
msg = msg + '%r user, %r sys, %r real\n' % (u, s, r)
|
||||
sys.stderr.write(msg)
|
||||
|
|
|
@ -77,7 +77,7 @@ def test():
|
|||
line = strip0(line)
|
||||
name = strip0(name)
|
||||
host = strip0(host)
|
||||
print `name`, `host`, `line`, time, idle
|
||||
print "%r %r %r %s %s" % (name, host, line, time, idle)
|
||||
|
||||
def testbcast():
|
||||
c = BroadcastRnusersClient('<broadcast>')
|
||||
|
|
|
@ -93,10 +93,10 @@ class Unpacker(xdr.Unpacker):
|
|||
xid = self.unpack_uint(xid)
|
||||
temp = self.unpack_enum()
|
||||
if temp <> CALL:
|
||||
raise BadRPCFormat, 'no CALL but ' + `temp`
|
||||
raise BadRPCFormat, 'no CALL but %r' % (temp,)
|
||||
temp = self.unpack_uint()
|
||||
if temp <> RPCVERSION:
|
||||
raise BadRPCVerspion, 'bad RPC version ' + `temp`
|
||||
raise BadRPCVerspion, 'bad RPC version %r' % (temp,)
|
||||
prog = self.unpack_uint()
|
||||
vers = self.unpack_uint()
|
||||
proc = self.unpack_uint()
|
||||
|
@ -109,7 +109,7 @@ class Unpacker(xdr.Unpacker):
|
|||
xid = self.unpack_uint()
|
||||
mtype = self.unpack_enum()
|
||||
if mtype <> REPLY:
|
||||
raise RuntimeError, 'no REPLY but ' + `mtype`
|
||||
raise RuntimeError, 'no REPLY but %r' % (mtype,)
|
||||
stat = self.unpack_enum()
|
||||
if stat == MSG_DENIED:
|
||||
stat = self.unpack_enum()
|
||||
|
@ -117,15 +117,15 @@ class Unpacker(xdr.Unpacker):
|
|||
low = self.unpack_uint()
|
||||
high = self.unpack_uint()
|
||||
raise RuntimeError, \
|
||||
'MSG_DENIED: RPC_MISMATCH: ' + `low, high`
|
||||
'MSG_DENIED: RPC_MISMATCH: %r' % ((low, high),)
|
||||
if stat == AUTH_ERROR:
|
||||
stat = self.unpack_uint()
|
||||
raise RuntimeError, \
|
||||
'MSG_DENIED: AUTH_ERROR: ' + `stat`
|
||||
raise RuntimeError, 'MSG_DENIED: ' + `stat`
|
||||
'MSG_DENIED: AUTH_ERROR: %r' % (stat,)
|
||||
raise RuntimeError, 'MSG_DENIED: %r' % (stat,)
|
||||
if stat <> MSG_ACCEPTED:
|
||||
raise RuntimeError, \
|
||||
'Neither MSG_DENIED nor MSG_ACCEPTED: ' + `stat`
|
||||
'Neither MSG_DENIED nor MSG_ACCEPTED: %r' % (stat,)
|
||||
verf = self.unpack_auth()
|
||||
stat = self.unpack_enum()
|
||||
if stat == PROG_UNAVAIL:
|
||||
|
@ -134,13 +134,13 @@ class Unpacker(xdr.Unpacker):
|
|||
low = self.unpack_uint()
|
||||
high = self.unpack_uint()
|
||||
raise RuntimeError, \
|
||||
'call failed: PROG_MISMATCH: ' + `low, high`
|
||||
'call failed: PROG_MISMATCH: %r' % ((low, high),)
|
||||
if stat == PROC_UNAVAIL:
|
||||
raise RuntimeError, 'call failed: PROC_UNAVAIL'
|
||||
if stat == GARBAGE_ARGS:
|
||||
raise RuntimeError, 'call failed: GARBAGE_ARGS'
|
||||
if stat <> SUCCESS:
|
||||
raise RuntimeError, 'call failed: ' + `stat`
|
||||
raise RuntimeError, 'call failed: %r' % (stat,)
|
||||
return xid, verf
|
||||
# Caller must get procedure-specific part of reply
|
||||
|
||||
|
@ -350,8 +350,8 @@ class RawTCPClient(Client):
|
|||
xid, verf = u.unpack_replyheader()
|
||||
if xid <> self.lastxid:
|
||||
# Can't really happen since this is TCP...
|
||||
raise RuntimeError, 'wrong xid in reply ' + `xid` + \
|
||||
' instead of ' + `self.lastxid`
|
||||
raise RuntimeError, 'wrong xid in reply %r instead of %r' % (
|
||||
xid, self.lastxid)
|
||||
|
||||
|
||||
# Client using UDP to a specific port
|
||||
|
@ -701,7 +701,7 @@ class Server:
|
|||
self.packer.pack_uint(self.vers)
|
||||
return self.packer.get_buf()
|
||||
proc = self.unpacker.unpack_uint()
|
||||
methname = 'handle_' + `proc`
|
||||
methname = 'handle_' + repr(proc)
|
||||
try:
|
||||
meth = getattr(self, methname)
|
||||
except AttributeError:
|
||||
|
@ -840,7 +840,7 @@ def testbcast():
|
|||
bcastaddr = '<broadcast>'
|
||||
def rh(reply, fromaddr):
|
||||
host, port = fromaddr
|
||||
print host + '\t' + `reply`
|
||||
print host + '\t' + repr(reply)
|
||||
pmap = BroadcastUDPPortMapperClient(bcastaddr)
|
||||
pmap.set_reply_handler(rh)
|
||||
pmap.set_timeout(5)
|
||||
|
@ -858,7 +858,7 @@ def testsvr():
|
|||
def handle_1(self):
|
||||
arg = self.unpacker.unpack_string()
|
||||
self.turn_around()
|
||||
print 'RPC function 1 called, arg', `arg`
|
||||
print 'RPC function 1 called, arg', repr(arg)
|
||||
self.packer.pack_string(arg + arg)
|
||||
#
|
||||
s = S('', 0x20000000, 1, 0)
|
||||
|
@ -888,4 +888,4 @@ def testclt():
|
|||
c = C(host, 0x20000000, 1)
|
||||
print 'making call...'
|
||||
reply = c.call_1('hello, world, ')
|
||||
print 'call returned', `reply`
|
||||
print 'call returned', repr(reply)
|
||||
|
|
|
@ -184,8 +184,7 @@ class Unpacker:
|
|||
x = self.unpack_uint()
|
||||
if x == 0: break
|
||||
if x <> 1:
|
||||
raise RuntimeError, \
|
||||
'0 or 1 expected, got ' + `x`
|
||||
raise RuntimeError, '0 or 1 expected, got %r' % (x, )
|
||||
item = unpack_item()
|
||||
list.append(item)
|
||||
return list
|
||||
|
|
|
@ -58,12 +58,12 @@ def ispython(name):
|
|||
return ispythonprog.match(name) >= 0
|
||||
|
||||
def recursedown(dirname):
|
||||
dbg('recursedown(' + `dirname` + ')\n')
|
||||
dbg('recursedown(%r)\n' % (dirname,))
|
||||
bad = 0
|
||||
try:
|
||||
names = os.listdir(dirname)
|
||||
except os.error, msg:
|
||||
err(dirname + ': cannot list directory: ' + `msg` + '\n')
|
||||
err('%s: cannot list directory: %r\n' % (dirname, msg))
|
||||
return 1
|
||||
names.sort()
|
||||
subdirs = []
|
||||
|
@ -80,11 +80,11 @@ def recursedown(dirname):
|
|||
return bad
|
||||
|
||||
def fix(filename):
|
||||
## dbg('fix(' + `filename` + ')\n')
|
||||
## dbg('fix(%r)\n' % (dirname,))
|
||||
try:
|
||||
f = open(filename, 'r')
|
||||
except IOError, msg:
|
||||
err(filename + ': cannot open: ' + `msg` + '\n')
|
||||
err('%s: cannot open: %r\n' % (filename, msg))
|
||||
return 1
|
||||
head, tail = os.path.split(filename)
|
||||
tempname = os.path.join(head, '@' + tail)
|
||||
|
@ -122,14 +122,13 @@ def fix(filename):
|
|||
g = open(tempname, 'w')
|
||||
except IOError, msg:
|
||||
f.close()
|
||||
err(tempname+': cannot create: '+\
|
||||
`msg`+'\n')
|
||||
err('%s: cannot create: %r\n' % (tempname, msg))
|
||||
return 1
|
||||
f.seek(0)
|
||||
lineno = 0
|
||||
rep(filename + ':\n')
|
||||
continue # restart from the beginning
|
||||
rep(`lineno` + '\n')
|
||||
rep(repr(lineno) + '\n')
|
||||
rep('< ' + line)
|
||||
rep('> ' + newline)
|
||||
if g is not None:
|
||||
|
@ -146,17 +145,17 @@ def fix(filename):
|
|||
statbuf = os.stat(filename)
|
||||
os.chmod(tempname, statbuf[ST_MODE] & 07777)
|
||||
except os.error, msg:
|
||||
err(tempname + ': warning: chmod failed (' + `msg` + ')\n')
|
||||
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(filename + ': warning: backup failed (' + `msg` + ')\n')
|
||||
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(filename + ': rename failed (' + `msg` + ')\n')
|
||||
err('%s: rename failed (%r)\n' % (filename, msg))
|
||||
return 1
|
||||
# Return succes
|
||||
return 0
|
||||
|
|
|
@ -31,5 +31,5 @@ while 1:
|
|||
if not line or line == '\n':
|
||||
break
|
||||
if line.startswith('Subject: '):
|
||||
print `line[9:-1]`,
|
||||
print repr(line[9:-1]),
|
||||
print
|
||||
|
|
|
@ -60,7 +60,7 @@ def main():
|
|||
if search and string.find(line, search) < 0:
|
||||
continue
|
||||
if prog.match(line) < 0:
|
||||
print 'Bad line', lineno, ':', `line`
|
||||
print 'Bad line', lineno, ':', repr(line)
|
||||
continue
|
||||
items = prog.group(1, 2, 3, 4, 5, 6)
|
||||
(logtime, loguser, loghost, logfile, logbytes,
|
||||
|
|
|
@ -83,24 +83,24 @@ def makestatus(name, thisuser):
|
|||
lines.append(line)
|
||||
#
|
||||
if totaljobs:
|
||||
line = `(totalbytes+1023)/1024` + ' K'
|
||||
line = '%d K' % ((totalbytes+1023)/1024)
|
||||
if totaljobs <> len(users):
|
||||
line = line + ' (' + `totaljobs` + ' jobs)'
|
||||
line = line + ' (%d jobs)' % totaljobs
|
||||
if len(users) == 1:
|
||||
line = line + ' for ' + users.keys()[0]
|
||||
line = line + ' for %s' % (users.keys()[0],)
|
||||
else:
|
||||
line = line + ' for ' + `len(users)` + ' users'
|
||||
line = line + ' for %d users' % len(users)
|
||||
if userseen:
|
||||
if aheadjobs == 0:
|
||||
line = line + ' (' + thisuser + ' first)'
|
||||
line = line + ' (%s first)' % thisuser
|
||||
else:
|
||||
line = line + ' (' + `(aheadbytes+1023)/1024`
|
||||
line = line + ' K before ' + thisuser + ')'
|
||||
line = line + ' (%d K before %s)' % (
|
||||
(aheadbytes+1023)/1024, thisuser)
|
||||
lines.append(line)
|
||||
#
|
||||
sts = pipe.close()
|
||||
if sts:
|
||||
lines.append('lpq exit status ' + `sts`)
|
||||
lines.append('lpq exit status %r' % (sts,))
|
||||
return string.joinfields(lines, ': ')
|
||||
|
||||
try:
|
||||
|
|
|
@ -89,8 +89,8 @@ def test():
|
|||
if debug > 1:
|
||||
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 repr(key), m.trans[key]
|
||||
if histsize == 0: print repr(''), m.trans['']
|
||||
print
|
||||
while 1:
|
||||
data = m.get()
|
||||
|
|
|
@ -73,7 +73,7 @@ def mmdf(f):
|
|||
sts = message(f, line) or sts
|
||||
else:
|
||||
sys.stderr.write(
|
||||
'Bad line in MMFD mailbox: %s\n' % `line`)
|
||||
'Bad line in MMFD mailbox: %r\n' % (line,))
|
||||
return sts
|
||||
|
||||
counter = 0 # for generating unique Message-ID headers
|
||||
|
@ -89,7 +89,7 @@ def message(f, delimiter = ''):
|
|||
t = time.mktime(tt)
|
||||
else:
|
||||
sys.stderr.write(
|
||||
'Unparseable date: %s\n' % `m.getheader('Date')`)
|
||||
'Unparseable date: %r\n' % (m.getheader('Date'),))
|
||||
t = os.fstat(f.fileno())[stat.ST_MTIME]
|
||||
print 'From', email, time.ctime(t)
|
||||
# Copy RFC822 header
|
||||
|
|
|
@ -12,13 +12,13 @@ def main():
|
|||
rcstree = 'RCStree'
|
||||
rcs = 'RCS'
|
||||
if os.path.islink(rcs):
|
||||
print `rcs`, 'is a symlink to', `os.readlink(rcs)`
|
||||
print '%r is a symlink to %r' % (rcs, os.readlink(rcs))
|
||||
return
|
||||
if os.path.isdir(rcs):
|
||||
print `rcs`, 'is an ordinary directory'
|
||||
print '%r is an ordinary directory' % (rcs,)
|
||||
return
|
||||
if os.path.exists(rcs):
|
||||
print `rcs`, 'is a file?!?!'
|
||||
print '%r is a file?!?!' % (rcs,)
|
||||
return
|
||||
#
|
||||
p = os.getcwd()
|
||||
|
@ -29,26 +29,26 @@ def main():
|
|||
# (2) up is the same directory as p
|
||||
# Ergo:
|
||||
# (3) join(up, down) is the current directory
|
||||
#print 'p =', `p`
|
||||
#print 'p =', repr(p)
|
||||
while not os.path.isdir(os.path.join(p, rcstree)):
|
||||
head, tail = os.path.split(p)
|
||||
#print 'head =', `head`, '; tail =', `tail`
|
||||
#print 'head = %r; tail = %r' % (head, tail)
|
||||
if not tail:
|
||||
print 'Sorry, no ancestor dir contains', `rcstree`
|
||||
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 =', `p`, '; up =', `up`, '; down =', `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 `there`, 'already exists'
|
||||
print '%r already exists' % (there, )
|
||||
else:
|
||||
print 'making', `there`
|
||||
print 'making %r' % (there,)
|
||||
makedirs(there)
|
||||
print 'making symlink', `rcs`, '->', `there`
|
||||
print 'making symlink %r -> %r' % (rcs, there)
|
||||
os.symlink(there, rcs)
|
||||
|
||||
def makedirs(p):
|
||||
|
|
|
@ -27,7 +27,7 @@ def main():
|
|||
def output(d):
|
||||
# Use write() to avoid spaces between the digits
|
||||
# Use int(d) to avoid a trailing L after each digit
|
||||
sys.stdout.write(`int(d)`)
|
||||
sys.stdout.write(repr(int(d)))
|
||||
# Flush so the output is seen immediately
|
||||
sys.stdout.flush()
|
||||
|
||||
|
|
|
@ -304,7 +304,7 @@ def getallgroups(server):
|
|||
def getnewgroups(server, treedate):
|
||||
print 'Getting list of new groups since start of '+treedate+'...',
|
||||
info = server.newgroups(treedate,'000001')[1]
|
||||
print 'got '+`len(info)`+'.'
|
||||
print 'got %d.' % len(info)
|
||||
print 'Processing...',
|
||||
groups = []
|
||||
for i in info:
|
||||
|
|
|
@ -125,6 +125,6 @@ fp.write(program)
|
|||
fp.flush()
|
||||
if DFLAG:
|
||||
import pdb
|
||||
pdb.run('execfile(' + `tfn` + ')')
|
||||
pdb.run('execfile(%r)' % (tfn,))
|
||||
else:
|
||||
execfile(tfn)
|
||||
|
|
|
@ -10,7 +10,7 @@ s.bind(('', 0))
|
|||
s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
|
||||
|
||||
while 1:
|
||||
data = `time.time()` + '\n'
|
||||
data = repr(time.time()) + '\n'
|
||||
s.sendto(data, ('<broadcast>', MYPORT))
|
||||
time.sleep(2)
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ def sendportcmd(s, f, port):
|
|||
hostname = gethostname()
|
||||
hostaddr = gethostbyname(hostname)
|
||||
hbytes = string.splitfields(hostaddr, '.')
|
||||
pbytes = [`port/256`, `port%256`]
|
||||
pbytes = [repr(port/256), repr(port%256)]
|
||||
bytes = hbytes + pbytes
|
||||
cmd = 'PORT ' + string.joinfields(bytes, ',')
|
||||
s.send(cmd + '\r\n')
|
||||
|
|
|
@ -75,10 +75,10 @@ def get_menu(selector, host, port):
|
|||
typechar = line[0]
|
||||
parts = string.splitfields(line[1:], TAB)
|
||||
if len(parts) < 4:
|
||||
print '(Bad line from server:', `line`, ')'
|
||||
print '(Bad line from server: %r)' % (line,)
|
||||
continue
|
||||
if len(parts) > 4:
|
||||
print '(Extra info from server:', parts[4:], ')'
|
||||
print '(Extra info from server: %r)' % (parts[4:],)
|
||||
parts.insert(0, typechar)
|
||||
list.append(parts)
|
||||
f.close()
|
||||
|
@ -154,17 +154,17 @@ def browse_menu(selector, host, port):
|
|||
list = get_menu(selector, host, port)
|
||||
while 1:
|
||||
print '----- MENU -----'
|
||||
print 'Selector:', `selector`
|
||||
print 'Selector:', repr(selector)
|
||||
print 'Host:', host, ' Port:', port
|
||||
print
|
||||
for i in range(len(list)):
|
||||
item = list[i]
|
||||
typechar, description = item[0], item[1]
|
||||
print string.rjust(`i+1`, 3) + ':', description,
|
||||
print string.rjust(repr(i+1), 3) + ':', description,
|
||||
if typename.has_key(typechar):
|
||||
print typename[typechar]
|
||||
else:
|
||||
print '<TYPE=' + `typechar` + '>'
|
||||
print '<TYPE=' + repr(typechar) + '>'
|
||||
print
|
||||
while 1:
|
||||
try:
|
||||
|
@ -221,7 +221,7 @@ def browse_textfile(selector, host, port):
|
|||
def browse_search(selector, host, port):
|
||||
while 1:
|
||||
print '----- SEARCH -----'
|
||||
print 'Selector:', `selector`
|
||||
print 'Selector:', repr(selector)
|
||||
print 'Host:', host, ' Port:', port
|
||||
print
|
||||
try:
|
||||
|
@ -240,9 +240,9 @@ def browse_search(selector, host, port):
|
|||
# "Browse" telnet-based information, i.e. open a telnet session
|
||||
def browse_telnet(selector, host, port):
|
||||
if selector:
|
||||
print 'Log in as', `selector`
|
||||
print 'Log in as', repr(selector)
|
||||
if type(port) <> type(''):
|
||||
port = `port`
|
||||
port = repr(port)
|
||||
sts = os.system('set -x; exec telnet ' + host + ' ' + port)
|
||||
if sts:
|
||||
print 'Exit status:', sts
|
||||
|
@ -307,18 +307,18 @@ def open_savefile():
|
|||
try:
|
||||
p = os.popen(cmd, 'w')
|
||||
except IOError, msg:
|
||||
print `cmd`, ':', msg
|
||||
print repr(cmd), ':', msg
|
||||
return None
|
||||
print 'Piping through', `cmd`, '...'
|
||||
print 'Piping through', repr(cmd), '...'
|
||||
return p
|
||||
if savefile[0] == '~':
|
||||
savefile = os.path.expanduser(savefile)
|
||||
try:
|
||||
f = open(savefile, 'w')
|
||||
except IOError, msg:
|
||||
print `savefile`, ':', msg
|
||||
print repr(savefile), ':', msg
|
||||
return None
|
||||
print 'Saving to', `savefile`, '...'
|
||||
print 'Saving to', repr(savefile), '...'
|
||||
return f
|
||||
|
||||
# Test program
|
||||
|
|
|
@ -38,7 +38,7 @@ def sender(flag):
|
|||
ttl = struct.pack('b', 1) # Time-to-live
|
||||
s.setsockopt(IPPROTO_IP, IP_MULTICAST_TTL, ttl)
|
||||
while 1:
|
||||
data = `time.time()`
|
||||
data = repr(time.time())
|
||||
## data = data + (1400 - len(data)) * '\0'
|
||||
s.sendto(data, (mygroup, MYPORT))
|
||||
time.sleep(1)
|
||||
|
@ -53,7 +53,7 @@ def receiver():
|
|||
while 1:
|
||||
data, sender = s.recvfrom(1500)
|
||||
while data[-1:] == '\0': data = data[:-1] # Strip trailing \0's
|
||||
print sender, ':', `data`
|
||||
print sender, ':', repr(data)
|
||||
|
||||
|
||||
# Open a UDP socket, bind it to a port and select a multicast group
|
||||
|
|
|
@ -10,5 +10,5 @@ s.bind(('', MYPORT))
|
|||
|
||||
while 1:
|
||||
data, wherefrom = s.recvfrom(1500, 0)
|
||||
sys.stderr.write(`wherefrom` + '\n')
|
||||
sys.stderr.write(repr(wherefrom) + '\n')
|
||||
sys.stdout.write(data)
|
||||
|
|
|
@ -53,7 +53,7 @@ def main():
|
|||
try:
|
||||
s.connect((host, port))
|
||||
except error, msg:
|
||||
sys.stderr.write('connect failed: ' + `msg` + '\n')
|
||||
sys.stderr.write('connect failed: ' + repr(msg) + '\n')
|
||||
sys.exit(1)
|
||||
#
|
||||
pid = posix.fork()
|
||||
|
|
|
@ -37,7 +37,7 @@ def server():
|
|||
print 'udp echo server ready'
|
||||
while 1:
|
||||
data, addr = s.recvfrom(BUFSIZE)
|
||||
print 'server received', `data`, 'from', `addr`
|
||||
print 'server received %r from %r' % (data, addr)
|
||||
s.sendto(data, addr)
|
||||
|
||||
def client():
|
||||
|
@ -58,6 +58,6 @@ def client():
|
|||
break
|
||||
s.sendto(line, addr)
|
||||
data, fromaddr = s.recvfrom(BUFSIZE)
|
||||
print 'client received', `data`, 'from', `fromaddr`
|
||||
print 'client received %r from %r' % (data, fromaddr)
|
||||
|
||||
main()
|
||||
|
|
|
@ -9,7 +9,7 @@ s = socket(AF_INET, SOCK_DGRAM)
|
|||
s.bind(('', 0))
|
||||
|
||||
while 1:
|
||||
data = `time.time()` + '\n'
|
||||
data = repr(time.time()) + '\n'
|
||||
s.sendto(data, ('', MYPORT))
|
||||
time.sleep(2)
|
||||
|
||||
|
|
|
@ -7,4 +7,4 @@ s.connect(FILE)
|
|||
s.send('Hello, world')
|
||||
data = s.recv(1024)
|
||||
s.close()
|
||||
print 'Received', `data`
|
||||
print 'Received', repr(data)
|
||||
|
|
|
@ -138,10 +138,9 @@ class Coroutine:
|
|||
|
||||
def tran(self, target, data=None):
|
||||
if not self.invokedby.has_key(target):
|
||||
raise TypeError, '.tran target ' + `target` + \
|
||||
' is not an active coroutine'
|
||||
raise TypeError, '.tran target %r is not an active coroutine' % (target,)
|
||||
if self.killed:
|
||||
raise TypeError, '.tran target ' + `target` + ' is killed'
|
||||
raise TypeError, '.tran target %r is killed' % (target,)
|
||||
self.value = data
|
||||
me = self.active
|
||||
self.invokedby[target] = me
|
||||
|
@ -153,7 +152,7 @@ class Coroutine:
|
|||
if self.main is not me:
|
||||
raise Killed
|
||||
if self.terminated_by is not None:
|
||||
raise EarlyExit, `self.terminated_by` + ' terminated early'
|
||||
raise EarlyExit, '%r terminated early' % (self.terminated_by,)
|
||||
|
||||
return self.value
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ def main():
|
|||
wq.run(nworkers)
|
||||
t2 = time.time()
|
||||
|
||||
sys.stderr.write('Total time ' + `t2-t1` + ' sec.\n')
|
||||
sys.stderr.write('Total time %r sec.\n' % (t2-t1))
|
||||
|
||||
|
||||
# The predicate -- defines what files we look for.
|
||||
|
@ -133,7 +133,7 @@ def find(dir, pred, wq):
|
|||
try:
|
||||
names = os.listdir(dir)
|
||||
except os.error, msg:
|
||||
print `dir`, ':', msg
|
||||
print repr(dir), ':', msg
|
||||
return
|
||||
for name in names:
|
||||
if name not in (os.curdir, os.pardir):
|
||||
|
@ -141,7 +141,7 @@ def find(dir, pred, wq):
|
|||
try:
|
||||
stat = os.lstat(fullname)
|
||||
except os.error, msg:
|
||||
print `fullname`, ':', msg
|
||||
print repr(fullname), ':', msg
|
||||
continue
|
||||
if pred(dir, name, fullname, stat):
|
||||
print fullname
|
||||
|
|
|
@ -336,7 +336,7 @@ class condition:
|
|||
|
||||
def broadcast(self, num = -1):
|
||||
if num < -1:
|
||||
raise ValueError, '.broadcast called with num ' + `num`
|
||||
raise ValueError, '.broadcast called with num %r' % (num,)
|
||||
if num == 0:
|
||||
return
|
||||
self.idlock.acquire()
|
||||
|
@ -418,7 +418,7 @@ class semaphore:
|
|||
self.nonzero.acquire()
|
||||
if self.count == self.maxcount:
|
||||
raise ValueError, '.v() tried to raise semaphore count above ' \
|
||||
'initial value ' + `maxcount`
|
||||
'initial value %r' % (maxcount,))
|
||||
self.count = self.count + 1
|
||||
self.nonzero.signal()
|
||||
self.nonzero.release()
|
||||
|
|
|
@ -57,7 +57,7 @@ def main():
|
|||
try:
|
||||
s.connect((host, port))
|
||||
except error, msg:
|
||||
sys.stderr.write('connect failed: ' + `msg` + '\n')
|
||||
sys.stderr.write('connect failed: %r\n' % (msg,))
|
||||
sys.exit(1)
|
||||
#
|
||||
thread.start_new(child, (s,))
|
||||
|
@ -77,7 +77,7 @@ def parent(s):
|
|||
for c in data:
|
||||
if opt:
|
||||
print ord(c)
|
||||
## print '(replying: ' + `opt+c` + ')'
|
||||
## print '(replying: %r)' % (opt+c,)
|
||||
s.send(opt + c)
|
||||
opt = ''
|
||||
elif iac:
|
||||
|
@ -101,13 +101,13 @@ def parent(s):
|
|||
cleandata = cleandata + c
|
||||
sys.stdout.write(cleandata)
|
||||
sys.stdout.flush()
|
||||
## print 'Out:', `cleandata`
|
||||
## print 'Out:', repr(cleandata)
|
||||
|
||||
def child(s):
|
||||
# read stdin, write socket
|
||||
while 1:
|
||||
line = sys.stdin.readline()
|
||||
## print 'Got:', `line`
|
||||
## print 'Got:', repr(line)
|
||||
if not line: break
|
||||
s.send(line)
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ class DemoDirList:
|
|||
top.btn['command'] = lambda dir=top.dir, ent=top.ent, self=self: \
|
||||
self.copy_name(dir,ent)
|
||||
|
||||
# top.ent.entry.insert(0,'tix'+`self`)
|
||||
# top.ent.entry.insert(0,'tix'+repr(self))
|
||||
top.ent.entry.bind('<Return>', lambda self=self: self.okcmd () )
|
||||
|
||||
top.pack( expand='yes', fill='both', side=TOP)
|
||||
|
|
|
@ -253,7 +253,7 @@ def refile_message(e=None):
|
|||
def fixfocus(near, itop):
|
||||
n = scanbox.size()
|
||||
for i in range(n):
|
||||
line = scanbox.get(`i`)
|
||||
line = scanbox.get(repr(i))
|
||||
if scanparser.match(line) >= 0:
|
||||
num = string.atoi(scanparser.group(1))
|
||||
if num >= near:
|
||||
|
|
|
@ -183,7 +183,7 @@ class Card:
|
|||
|
||||
def __repr__(self):
|
||||
"""Return a string for debug print statements."""
|
||||
return "Card(%s, %s)" % (`self.suit`, `self.value`)
|
||||
return "Card(%r, %r)" % (self.suit, self.value)
|
||||
|
||||
def moveto(self, x, y):
|
||||
"""Move the card to absolute position (x, y)."""
|
||||
|
|
|
@ -28,7 +28,7 @@ class Test(Frame):
|
|||
def moveThing(self, *args):
|
||||
velocity = self.speed.get()
|
||||
str = float(velocity) / 1000.0
|
||||
str = `str` + "i"
|
||||
str = "%ri" % (str,)
|
||||
self.draw.move("thing", str, str)
|
||||
self.after(10, self.moveThing)
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class Pong(Frame):
|
|||
self.x = self.x + deltax
|
||||
self.y = self.y + deltay
|
||||
|
||||
self.draw.move(self.ball, `deltax` + "i", `deltay` + "i")
|
||||
self.draw.move(self.ball, "%ri" % deltax, "%ri" % deltay)
|
||||
self.after(10, self.moveBall)
|
||||
|
||||
def __init__(self, master=None):
|
||||
|
|
|
@ -47,10 +47,10 @@ if __name__ == "__main__":
|
|||
print "not ok: no conflict between -h and -H"
|
||||
|
||||
parser.add_option("-f", "--file", dest="file")
|
||||
#print `parser.get_option("-f")`
|
||||
#print `parser.get_option("-F")`
|
||||
#print `parser.get_option("--file")`
|
||||
#print `parser.get_option("--fIlE")`
|
||||
#print repr(parser.get_option("-f"))
|
||||
#print repr(parser.get_option("-F"))
|
||||
#print repr(parser.get_option("--file"))
|
||||
#print repr(parser.get_option("--fIlE"))
|
||||
(options, args) = parser.parse_args(["--FiLe", "foo"])
|
||||
assert options.file == "foo", options.file
|
||||
print "ok: case insensitive long options work"
|
||||
|
|
|
@ -78,4 +78,4 @@ class RepositoryInfo:
|
|||
return fn[len(self.cvsroot_path)+1:]
|
||||
|
||||
def __repr__(self):
|
||||
return "<RepositoryInfo for %s>" % `self.get_cvsroot()`
|
||||
return "<RepositoryInfo for %r>" % self.get_cvsroot()
|
||||
|
|
|
@ -32,7 +32,7 @@ def loadfile(fp):
|
|||
continue
|
||||
parts = line.split(":", 4)
|
||||
if len(parts) != 5:
|
||||
raise ValueError("Not enough fields in " + `line`)
|
||||
raise ValueError("Not enough fields in %r" % line)
|
||||
function, type, arg, refcount, comment = parts
|
||||
if refcount == "null":
|
||||
refcount = None
|
||||
|
|
|
@ -29,7 +29,7 @@ def decode(s):
|
|||
n, s = s.split(";", 1)
|
||||
r = r + unichr(int(n))
|
||||
else:
|
||||
raise ValueError, "can't handle " + `s`
|
||||
raise ValueError, "can't handle %r" % s
|
||||
return r
|
||||
|
||||
|
||||
|
@ -220,8 +220,8 @@ class ESISReader(xml.sax.xmlreader.XMLReader):
|
|||
return self._decl_handler
|
||||
|
||||
else:
|
||||
raise xml.sax.SAXNotRecognizedException("unknown property %s"
|
||||
% `property`)
|
||||
raise xml.sax.SAXNotRecognizedException("unknown property %r"
|
||||
% (property, ))
|
||||
|
||||
def setProperty(self, property, value):
|
||||
if property == xml.sax.handler.property_lexical_handler:
|
||||
|
|
|
@ -73,8 +73,8 @@ def popping(name, point, depth):
|
|||
class _Stack(list):
|
||||
def append(self, entry):
|
||||
if not isinstance(entry, str):
|
||||
raise LaTeXFormatError("cannot push non-string on stack: "
|
||||
+ `entry`)
|
||||
raise LaTeXFormatError("cannot push non-string on stack: %r"
|
||||
% (entry, ))
|
||||
#dbgmsg("%s<%s>" % (" "*len(self.data), entry))
|
||||
list.append(self, entry)
|
||||
|
||||
|
@ -208,8 +208,8 @@ class Conversion:
|
|||
m = _parameter_rx.match(line)
|
||||
if not m:
|
||||
raise LaTeXFormatError(
|
||||
"could not extract parameter %s for %s: %s"
|
||||
% (pentry.name, macroname, `line[:100]`))
|
||||
"could not extract parameter %s for %s: %r"
|
||||
% (pentry.name, macroname, line[:100]))
|
||||
if entry.outputname:
|
||||
self.dump_attr(pentry, m.group(1))
|
||||
line = line[m.end():]
|
||||
|
@ -259,7 +259,7 @@ class Conversion:
|
|||
opened = 1
|
||||
stack.append(entry.name)
|
||||
self.write("(%s\n" % entry.outputname)
|
||||
#dbgmsg("--- text: %s" % `pentry.text`)
|
||||
#dbgmsg("--- text: %r" % pentry.text)
|
||||
self.write("-%s\n" % encode(pentry.text))
|
||||
elif pentry.type == "entityref":
|
||||
self.write("&%s\n" % pentry.name)
|
||||
|
@ -326,8 +326,8 @@ class Conversion:
|
|||
extra = ""
|
||||
if len(line) > 100:
|
||||
extra = "..."
|
||||
raise LaTeXFormatError("could not identify markup: %s%s"
|
||||
% (`line[:100]`, extra))
|
||||
raise LaTeXFormatError("could not identify markup: %r%s"
|
||||
% (line[:100], extra))
|
||||
while stack:
|
||||
entry = self.get_entry(stack[-1])
|
||||
if entry.closes:
|
||||
|
@ -361,7 +361,7 @@ class Conversion:
|
|||
def get_entry(self, name):
|
||||
entry = self.table.get(name)
|
||||
if entry is None:
|
||||
dbgmsg("get_entry(%s) failing; building default entry!" % `name`)
|
||||
dbgmsg("get_entry(%r) failing; building default entry!" % (name, ))
|
||||
# not defined; build a default entry:
|
||||
entry = TableEntry(name)
|
||||
entry.has_content = 1
|
||||
|
@ -486,7 +486,7 @@ class TableHandler(xml.sax.handler.ContentHandler):
|
|||
def end_macro(self):
|
||||
name = self.__current.name
|
||||
if self.__table.has_key(name):
|
||||
raise ValueError("name %s already in use" % `name`)
|
||||
raise ValueError("name %r already in use" % (name,))
|
||||
self.__table[name] = self.__current
|
||||
self.__current = None
|
||||
|
||||
|
|
|
@ -238,7 +238,7 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
|
|||
if len(words) == 3:
|
||||
[command, path, version] = words
|
||||
if version[:5] != 'HTTP/':
|
||||
self.send_error(400, "Bad request version (%s)" % `version`)
|
||||
self.send_error(400, "Bad request version (%r)" % version)
|
||||
return False
|
||||
try:
|
||||
base_version_number = version.split('/', 1)[1]
|
||||
|
@ -253,7 +253,7 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
|
|||
raise ValueError
|
||||
version_number = int(version_number[0]), int(version_number[1])
|
||||
except (ValueError, IndexError):
|
||||
self.send_error(400, "Bad request version (%s)" % `version`)
|
||||
self.send_error(400, "Bad request version (%r)" % version)
|
||||
return False
|
||||
if version_number >= (1, 1) and self.protocol_version >= "HTTP/1.1":
|
||||
self.close_connection = 0
|
||||
|
@ -266,12 +266,12 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
|
|||
self.close_connection = 1
|
||||
if command != 'GET':
|
||||
self.send_error(400,
|
||||
"Bad HTTP/0.9 request type (%s)" % `command`)
|
||||
"Bad HTTP/0.9 request type (%r)" % command)
|
||||
return False
|
||||
elif not words:
|
||||
return False
|
||||
else:
|
||||
self.send_error(400, "Bad request syntax (%s)" % `requestline`)
|
||||
self.send_error(400, "Bad request syntax (%r)" % requestline)
|
||||
return False
|
||||
self.command, self.path, self.request_version = command, path, version
|
||||
|
||||
|
@ -302,7 +302,7 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
|
|||
return
|
||||
mname = 'do_' + self.command
|
||||
if not hasattr(self, mname):
|
||||
self.send_error(501, "Unsupported method (%s)" % `self.command`)
|
||||
self.send_error(501, "Unsupported method (%r)" % self.command)
|
||||
return
|
||||
method = getattr(self, mname)
|
||||
method()
|
||||
|
|
|
@ -124,7 +124,7 @@ def Bastion(object, filter = lambda name: name[:1] != '_',
|
|||
return get1(name)
|
||||
|
||||
if name is None:
|
||||
name = `object`
|
||||
name = repr(object)
|
||||
return bastionclass(get2, name)
|
||||
|
||||
|
||||
|
|
|
@ -117,21 +117,21 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
|||
scriptname = dir + '/' + script
|
||||
scriptfile = self.translate_path(scriptname)
|
||||
if not os.path.exists(scriptfile):
|
||||
self.send_error(404, "No such CGI script (%s)" % `scriptname`)
|
||||
self.send_error(404, "No such CGI script (%r)" % scriptname)
|
||||
return
|
||||
if not os.path.isfile(scriptfile):
|
||||
self.send_error(403, "CGI script is not a plain file (%s)" %
|
||||
`scriptname`)
|
||||
self.send_error(403, "CGI script is not a plain file (%r)" %
|
||||
scriptname)
|
||||
return
|
||||
ispy = self.is_python(scriptname)
|
||||
if not ispy:
|
||||
if not (self.have_fork or self.have_popen2 or self.have_popen3):
|
||||
self.send_error(403, "CGI script is not a Python script (%s)" %
|
||||
`scriptname`)
|
||||
self.send_error(403, "CGI script is not a Python script (%r)" %
|
||||
scriptname)
|
||||
return
|
||||
if not self.is_executable(scriptfile):
|
||||
self.send_error(403, "CGI script is not executable (%s)" %
|
||||
`scriptname`)
|
||||
self.send_error(403, "CGI script is not executable (%r)" %
|
||||
scriptname)
|
||||
return
|
||||
|
||||
# Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html
|
||||
|
|
|
@ -118,7 +118,7 @@ class NoSectionError(Error):
|
|||
"""Raised when no section matches a requested option."""
|
||||
|
||||
def __init__(self, section):
|
||||
Error.__init__(self, 'No section: ' + `section`)
|
||||
Error.__init__(self, 'No section: %r' % (section,))
|
||||
self.section = section
|
||||
|
||||
class DuplicateSectionError(Error):
|
||||
|
@ -191,7 +191,7 @@ class MissingSectionHeaderError(ParsingError):
|
|||
def __init__(self, filename, lineno, line):
|
||||
Error.__init__(
|
||||
self,
|
||||
'File contains no section headers.\nfile: %s, line: %d\n%s' %
|
||||
'File contains no section headers.\nfile: %s, line: %d\n%r' %
|
||||
(filename, lineno, line))
|
||||
self.filename = filename
|
||||
self.lineno = lineno
|
||||
|
@ -453,7 +453,7 @@ class RawConfigParser:
|
|||
optname = None
|
||||
# no section header in the file?
|
||||
elif cursect is None:
|
||||
raise MissingSectionHeaderError(fpname, lineno, `line`)
|
||||
raise MissingSectionHeaderError(fpname, lineno, line)
|
||||
# an option line?
|
||||
else:
|
||||
mo = self.OPTCRE.match(line)
|
||||
|
@ -478,7 +478,7 @@ class RawConfigParser:
|
|||
# list of all bogus lines
|
||||
if not e:
|
||||
e = ParsingError(fpname)
|
||||
e.append(lineno, `line`)
|
||||
e.append(lineno, repr(line))
|
||||
# if any parsing errors occurred, raise an exception
|
||||
if e:
|
||||
raise e
|
||||
|
@ -613,4 +613,4 @@ class SafeConfigParser(ConfigParser):
|
|||
else:
|
||||
raise InterpolationSyntaxError(
|
||||
option, section,
|
||||
"'%' must be followed by '%' or '(', found: " + `rest`)
|
||||
"'%%' must be followed by '%%' or '(', found: %r" % (rest,))
|
||||
|
|
|
@ -272,8 +272,8 @@ class HTMLParser(markupbase.ParserBase):
|
|||
- self.__starttag_text.rfind("\n")
|
||||
else:
|
||||
offset = offset + len(self.__starttag_text)
|
||||
self.error("junk characters in start tag: %s"
|
||||
% `rawdata[k:endpos][:20]`)
|
||||
self.error("junk characters in start tag: %r"
|
||||
% (rawdata[k:endpos][:20],))
|
||||
if end.endswith('/>'):
|
||||
# XHTML-style empty tag: <span attr="value" />
|
||||
self.handle_startendtag(tag, attrs)
|
||||
|
@ -324,7 +324,7 @@ class HTMLParser(markupbase.ParserBase):
|
|||
j = match.end()
|
||||
match = endtagfind.match(rawdata, i) # </ + tag + >
|
||||
if not match:
|
||||
self.error("bad end tag: %s" % `rawdata[i:j]`)
|
||||
self.error("bad end tag: %r" % (rawdata[i:j],))
|
||||
tag = match.group(1)
|
||||
self.handle_endtag(tag.lower())
|
||||
self.clear_cdata_mode()
|
||||
|
@ -368,7 +368,7 @@ class HTMLParser(markupbase.ParserBase):
|
|||
pass
|
||||
|
||||
def unknown_decl(self, data):
|
||||
self.error("unknown declaration: " + `data`)
|
||||
self.error("unknown declaration: %r" % (data,))
|
||||
|
||||
# Internal -- helper to remove special character quoting
|
||||
def unescape(self, s):
|
||||
|
|
|
@ -222,10 +222,10 @@ def test():
|
|||
f.seek(len(lines[0]))
|
||||
f.write(lines[1])
|
||||
f.seek(0)
|
||||
print 'First line =', `f.readline()`
|
||||
print 'First line =', repr(f.readline())
|
||||
print 'Position =', f.tell()
|
||||
line = f.readline()
|
||||
print 'Second line =', `line`
|
||||
print 'Second line =', repr(line)
|
||||
f.seek(-len(line), 1)
|
||||
line2 = f.read(len(line))
|
||||
if line != line2:
|
||||
|
|
|
@ -392,7 +392,7 @@ class Aifc_read:
|
|||
for marker in self._markers:
|
||||
if id == marker[0]:
|
||||
return marker
|
||||
raise Error, 'marker ' + `id` + ' does not exist'
|
||||
raise Error, 'marker %r does not exist' % (id,)
|
||||
|
||||
def setpos(self, pos):
|
||||
if pos < 0 or pos > self._nframes:
|
||||
|
@ -697,7 +697,7 @@ class Aifc_write:
|
|||
for marker in self._markers:
|
||||
if id == marker[0]:
|
||||
return marker
|
||||
raise Error, 'marker ' + `id` + ' does not exist'
|
||||
raise Error, 'marker %r does not exist' % (id,)
|
||||
|
||||
def getmarkers(self):
|
||||
if len(self._markers) == 0:
|
||||
|
|
|
@ -40,9 +40,9 @@ if __name__ == "__main__":
|
|||
def x1():
|
||||
print "running x1"
|
||||
def x2(n):
|
||||
print "running x2(%s)" % `n`
|
||||
print "running x2(%r)" % (n,)
|
||||
def x3(n, kwd=None):
|
||||
print "running x3(%s, kwd=%s)" % (`n`, `kwd`)
|
||||
print "running x3(%r, kwd=%r)" % (n, kwd)
|
||||
|
||||
register(x1)
|
||||
register(x2, 12)
|
||||
|
|
|
@ -348,7 +348,7 @@ def test1():
|
|||
s0 = "Aladdin:open sesame"
|
||||
s1 = encodestring(s0)
|
||||
s2 = decodestring(s1)
|
||||
print s0, `s1`, s2
|
||||
print s0, repr(s1), s2
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -52,7 +52,7 @@ class Bdb:
|
|||
return self.dispatch_return(frame, arg)
|
||||
if event == 'exception':
|
||||
return self.dispatch_exception(frame, arg)
|
||||
print 'bdb.Bdb.dispatch: unknown debugging event:', `event`
|
||||
print 'bdb.Bdb.dispatch: unknown debugging event:', repr(event)
|
||||
return self.trace_dispatch
|
||||
|
||||
def dispatch_line(self, frame):
|
||||
|
@ -311,7 +311,7 @@ class Bdb:
|
|||
import linecache, repr
|
||||
frame, lineno = frame_lineno
|
||||
filename = self.canonic(frame.f_code.co_filename)
|
||||
s = filename + '(' + `lineno` + ')'
|
||||
s = '%s(%r)' % (filename, lineno)
|
||||
if frame.f_code.co_name:
|
||||
s = s + frame.f_code.co_name
|
||||
else:
|
||||
|
|
|
@ -229,7 +229,7 @@ class BinHex:
|
|||
|
||||
def close_data(self):
|
||||
if self.dlen != 0:
|
||||
raise Error, 'Incorrect data size, diff='+`self.rlen`
|
||||
raise Error, 'Incorrect data size, diff=%r' % (self.rlen,)
|
||||
self._writecrc()
|
||||
self.state = _DID_DATA
|
||||
|
||||
|
@ -248,7 +248,7 @@ class BinHex:
|
|||
raise Error, 'Close at the wrong time'
|
||||
if self.rlen != 0:
|
||||
raise Error, \
|
||||
"Incorrect resource-datasize, diff="+`self.rlen`
|
||||
"Incorrect resource-datasize, diff=%r" % (self.rlen,)
|
||||
self._writecrc()
|
||||
self.ofp.close()
|
||||
self.state = None
|
||||
|
|
|
@ -164,10 +164,10 @@ def _test():
|
|||
f.seek(len(lines[0]))
|
||||
f.write(lines[1])
|
||||
f.seek(0)
|
||||
print 'First line =', `f.readline()`
|
||||
print 'First line =', repr(f.readline())
|
||||
here = f.tell()
|
||||
line = f.readline()
|
||||
print 'Second line =', `line`
|
||||
print 'Second line =', repr(line)
|
||||
f.seek(-len(line), 1)
|
||||
line2 = f.read(len(line))
|
||||
if line != line2:
|
||||
|
|
|
@ -206,7 +206,7 @@ class bsdTableDB :
|
|||
try:
|
||||
key, data = cur.first()
|
||||
while 1:
|
||||
print `{key: data}`
|
||||
print repr({key: data})
|
||||
next = cur.next()
|
||||
if next:
|
||||
key, data = next
|
||||
|
@ -341,9 +341,9 @@ class bsdTableDB :
|
|||
try:
|
||||
tcolpickles = self.db.get(_columns_key(table))
|
||||
except DBNotFoundError:
|
||||
raise TableDBError, "unknown table: " + `table`
|
||||
raise TableDBError, "unknown table: %r" % (table,)
|
||||
if not tcolpickles:
|
||||
raise TableDBError, "unknown table: " + `table`
|
||||
raise TableDBError, "unknown table: %r" % (table,)
|
||||
self.__tablecolumns[table] = pickle.loads(tcolpickles)
|
||||
|
||||
def __new_rowid(self, table, txn) :
|
||||
|
@ -384,7 +384,7 @@ class bsdTableDB :
|
|||
self.__load_column_info(table)
|
||||
for column in rowdict.keys() :
|
||||
if not self.__tablecolumns[table].count(column):
|
||||
raise TableDBError, "unknown column: "+`column`
|
||||
raise TableDBError, "unknown column: %r" % (column,)
|
||||
|
||||
# get a unique row identifier for this row
|
||||
txn = self.env.txn_begin()
|
||||
|
@ -535,7 +535,7 @@ class bsdTableDB :
|
|||
columns = self.tablecolumns[table]
|
||||
for column in (columns + conditions.keys()):
|
||||
if not self.__tablecolumns[table].count(column):
|
||||
raise TableDBError, "unknown column: "+`column`
|
||||
raise TableDBError, "unknown column: %r" % (column,)
|
||||
|
||||
# keyed on rows that match so far, containings dicts keyed on
|
||||
# column names containing the data for that row and column.
|
||||
|
|
|
@ -200,7 +200,7 @@ class AssociateTestCase(unittest.TestCase):
|
|||
def getGenre(self, priKey, priData):
|
||||
assert type(priData) == type("")
|
||||
if verbose:
|
||||
print 'getGenre key:', `priKey`, 'data:', `priData`
|
||||
print 'getGenre key: %r data: %r' % (priKey, priData)
|
||||
genre = string.split(priData, '|')[2]
|
||||
if genre == 'Blues':
|
||||
return db.DB_DONOTINDEX
|
||||
|
@ -242,7 +242,7 @@ class ShelveAssociateTestCase(AssociateTestCase):
|
|||
def getGenre(self, priKey, priData):
|
||||
assert type(priData) == type(())
|
||||
if verbose:
|
||||
print 'getGenre key:', `priKey`, 'data:', `priData`
|
||||
print 'getGenre key: %r data: %r' % (priKey, priData)
|
||||
genre = priData[2]
|
||||
if genre == 'Blues':
|
||||
return db.DB_DONOTINDEX
|
||||
|
|
|
@ -361,7 +361,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
if set_raises_error:
|
||||
self.fail("expected exception")
|
||||
if n != None:
|
||||
self.fail("expected None: "+`n`)
|
||||
self.fail("expected None: %r" % (n,))
|
||||
|
||||
rec = c.get_both('0404', self.makeData('0404'))
|
||||
assert rec == ('0404', self.makeData('0404'))
|
||||
|
@ -375,7 +375,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
if get_raises_error:
|
||||
self.fail("expected exception")
|
||||
if n != None:
|
||||
self.fail("expected None: "+`n`)
|
||||
self.fail("expected None: %r" % (n,))
|
||||
|
||||
if self.d.get_type() == db.DB_BTREE:
|
||||
rec = c.set_range('011')
|
||||
|
@ -548,7 +548,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
num = d.truncate()
|
||||
assert num >= 1, "truncate returned <= 0 on non-empty database"
|
||||
num = d.truncate()
|
||||
assert num == 0, "truncate on empty DB returned nonzero (%s)" % `num`
|
||||
assert num == 0, "truncate on empty DB returned nonzero (%r)" % (num,)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
@ -674,7 +674,7 @@ class BasicTransactionTestCase(BasicTestCase):
|
|||
num = d.truncate(txn)
|
||||
assert num >= 1, "truncate returned <= 0 on non-empty database"
|
||||
num = d.truncate(txn)
|
||||
assert num == 0, "truncate on empty DB returned nonzero (%s)" % `num`
|
||||
assert num == 0, "truncate on empty DB returned nonzero (%r)" % (num,)
|
||||
txn.commit()
|
||||
|
||||
#----------------------------------------
|
||||
|
|
|
@ -109,7 +109,7 @@ class TableDBTestCase(unittest.TestCase):
|
|||
assert values[1]['Species'] == 'Penguin'
|
||||
else :
|
||||
if verbose:
|
||||
print "values=", `values`
|
||||
print "values= %r" % (values,)
|
||||
raise "Wrong values returned!"
|
||||
|
||||
def test03(self):
|
||||
|
|
|
@ -151,9 +151,9 @@ def month(theyear, themonth, w=0, l=0):
|
|||
"""Return a month's calendar string (multi-line)."""
|
||||
w = max(2, w)
|
||||
l = max(1, l)
|
||||
s = ((month_name[themonth] + ' ' + `theyear`).center(
|
||||
7 * (w + 1) - 1).rstrip() +
|
||||
'\n' * l + weekheader(w).rstrip() + '\n' * l)
|
||||
s = ("%s %r" % (month_name[themonth], theyear)).center(
|
||||
7 * (w + 1) - 1).rstrip() + \
|
||||
'\n' * l + weekheader(w).rstrip() + '\n' * l
|
||||
for aweek in monthcalendar(theyear, themonth):
|
||||
s = s + week(aweek, w).rstrip() + '\n' * l
|
||||
return s[:-l] + '\n'
|
||||
|
@ -181,7 +181,7 @@ def calendar(year, w=0, l=0, c=_spacing):
|
|||
l = max(1, l)
|
||||
c = max(2, c)
|
||||
colwidth = (w + 1) * 7 - 1
|
||||
s = `year`.center(colwidth * 3 + c * 2).rstrip() + '\n' * l
|
||||
s = repr(year).center(colwidth * 3 + c * 2).rstrip() + '\n' * l
|
||||
header = weekheader(w)
|
||||
header = format3cstring(header, header, header, colwidth, c).rstrip()
|
||||
for q in range(January, January+12, 3):
|
||||
|
|
19
Lib/cgi.py
19
Lib/cgi.py
|
@ -212,7 +212,7 @@ def parse_qsl(qs, keep_blank_values=0, strict_parsing=0):
|
|||
nv = name_value.split('=', 1)
|
||||
if len(nv) != 2:
|
||||
if strict_parsing:
|
||||
raise ValueError, "bad query field: %s" % `name_value`
|
||||
raise ValueError, "bad query field: %r" % (name_value,)
|
||||
continue
|
||||
if len(nv[1]) or keep_blank_values:
|
||||
name = urllib.unquote(nv[0].replace('+', ' '))
|
||||
|
@ -247,8 +247,8 @@ def parse_multipart(fp, pdict):
|
|||
if 'boundary' in pdict:
|
||||
boundary = pdict['boundary']
|
||||
if not valid_boundary(boundary):
|
||||
raise ValueError, ('Invalid boundary in multipart form: %s'
|
||||
% `boundary`)
|
||||
raise ValueError, ('Invalid boundary in multipart form: %r'
|
||||
% (boundary,))
|
||||
|
||||
nextpart = "--" + boundary
|
||||
lastpart = "--" + boundary + "--"
|
||||
|
@ -361,7 +361,7 @@ class MiniFieldStorage:
|
|||
|
||||
def __repr__(self):
|
||||
"""Return printable representation."""
|
||||
return "MiniFieldStorage(%s, %s)" % (`self.name`, `self.value`)
|
||||
return "MiniFieldStorage(%r, %r)" % (self.name, self.value)
|
||||
|
||||
|
||||
class FieldStorage:
|
||||
|
@ -522,8 +522,8 @@ class FieldStorage:
|
|||
|
||||
def __repr__(self):
|
||||
"""Return a printable representation."""
|
||||
return "FieldStorage(%s, %s, %s)" % (
|
||||
`self.name`, `self.filename`, `self.value`)
|
||||
return "FieldStorage(%r, %r, %r)" % (
|
||||
self.name, self.filename, self.value)
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self.keys())
|
||||
|
@ -632,8 +632,7 @@ class FieldStorage:
|
|||
"""Internal: read a part that is itself multipart."""
|
||||
ib = self.innerboundary
|
||||
if not valid_boundary(ib):
|
||||
raise ValueError, ('Invalid boundary in multipart form: %s'
|
||||
% `ib`)
|
||||
raise ValueError, 'Invalid boundary in multipart form: %r' % (ib,)
|
||||
self.list = []
|
||||
klass = self.FieldStorageClass or self.__class__
|
||||
part = klass(self.fp, {}, ib,
|
||||
|
@ -957,8 +956,8 @@ def print_form(form):
|
|||
for key in keys:
|
||||
print "<DT>" + escape(key) + ":",
|
||||
value = form[key]
|
||||
print "<i>" + escape(`type(value)`) + "</i>"
|
||||
print "<DD>" + escape(`value`)
|
||||
print "<i>" + escape(repr(type(value))) + "</i>"
|
||||
print "<DD>" + escape(repr(value))
|
||||
print "</DL>"
|
||||
print
|
||||
|
||||
|
|
|
@ -689,9 +689,9 @@ def get_close_matches(word, possibilities, n=3, cutoff=0.6):
|
|||
"""
|
||||
|
||||
if not n > 0:
|
||||
raise ValueError("n must be > 0: " + `n`)
|
||||
raise ValueError("n must be > 0: %r" % (n,))
|
||||
if not 0.0 <= cutoff <= 1.0:
|
||||
raise ValueError("cutoff must be in [0.0, 1.0]: " + `cutoff`)
|
||||
raise ValueError("cutoff must be in [0.0, 1.0]: %r" % (cutoff,))
|
||||
result = []
|
||||
s = SequenceMatcher()
|
||||
s.set_seq2(word)
|
||||
|
@ -876,7 +876,7 @@ class Differ:
|
|||
elif tag == 'equal':
|
||||
g = self._dump(' ', a, alo, ahi)
|
||||
else:
|
||||
raise ValueError, 'unknown tag ' + `tag`
|
||||
raise ValueError, 'unknown tag %r' % (tag,)
|
||||
|
||||
for line in g:
|
||||
yield line
|
||||
|
@ -988,7 +988,7 @@ class Differ:
|
|||
atags += ' ' * la
|
||||
btags += ' ' * lb
|
||||
else:
|
||||
raise ValueError, 'unknown tag ' + `tag`
|
||||
raise ValueError, 'unknown tag %r' % (tag,)
|
||||
for line in self._qformat(aelt, belt, atags, btags):
|
||||
yield line
|
||||
else:
|
||||
|
|
16
Lib/dis.py
16
Lib/dis.py
|
@ -80,7 +80,7 @@ def disassemble(co, lasti=-1):
|
|||
else: print ' ',
|
||||
if i in labels: print '>>',
|
||||
else: print ' ',
|
||||
print `i`.rjust(4),
|
||||
print repr(i).rjust(4),
|
||||
print opname[op].ljust(20),
|
||||
i = i+1
|
||||
if op >= HAVE_ARGUMENT:
|
||||
|
@ -89,13 +89,13 @@ def disassemble(co, lasti=-1):
|
|||
i = i+2
|
||||
if op == EXTENDED_ARG:
|
||||
extended_arg = oparg*65536L
|
||||
print `oparg`.rjust(5),
|
||||
print repr(oparg).rjust(5),
|
||||
if op in hasconst:
|
||||
print '(' + `co.co_consts[oparg]` + ')',
|
||||
print '(' + repr(co.co_consts[oparg]) + ')',
|
||||
elif op in hasname:
|
||||
print '(' + co.co_names[oparg] + ')',
|
||||
elif op in hasjrel:
|
||||
print '(to ' + `i + oparg` + ')',
|
||||
print '(to ' + repr(i + oparg) + ')',
|
||||
elif op in haslocal:
|
||||
print '(' + co.co_varnames[oparg] + ')',
|
||||
elif op in hascompare:
|
||||
|
@ -118,16 +118,16 @@ def disassemble_string(code, lasti=-1, varnames=None, names=None,
|
|||
else: print ' ',
|
||||
if i in labels: print '>>',
|
||||
else: print ' ',
|
||||
print `i`.rjust(4),
|
||||
print repr(i).rjust(4),
|
||||
print opname[op].ljust(15),
|
||||
i = i+1
|
||||
if op >= HAVE_ARGUMENT:
|
||||
oparg = ord(code[i]) + ord(code[i+1])*256
|
||||
i = i+2
|
||||
print `oparg`.rjust(5),
|
||||
print repr(oparg).rjust(5),
|
||||
if op in hasconst:
|
||||
if constants:
|
||||
print '(' + `constants[oparg]` + ')',
|
||||
print '(' + repr(constants[oparg]) + ')',
|
||||
else:
|
||||
print '(%d)'%oparg,
|
||||
elif op in hasname:
|
||||
|
@ -136,7 +136,7 @@ def disassemble_string(code, lasti=-1, varnames=None, names=None,
|
|||
else:
|
||||
print '(%d)'%oparg,
|
||||
elif op in hasjrel:
|
||||
print '(to ' + `i + oparg` + ')',
|
||||
print '(to ' + repr(i + oparg) + ')',
|
||||
elif op in haslocal:
|
||||
if varnames:
|
||||
print '(' + varnames[oparg] + ')',
|
||||
|
|
|
@ -253,8 +253,8 @@ class Command:
|
|||
|
||||
if not ok:
|
||||
raise DistutilsOptionError, \
|
||||
"'%s' must be a list of strings (got %s)" % \
|
||||
(option, `val`)
|
||||
"'%s' must be a list of strings (got %r)" % \
|
||||
(option, val)
|
||||
|
||||
def _ensure_tested_string (self, option, tester,
|
||||
what, error_fmt, default=None):
|
||||
|
|
|
@ -202,7 +202,7 @@ def run_setup (script_name, script_args=None, stop_after="run"):
|
|||
used to drive the Distutils.
|
||||
"""
|
||||
if stop_after not in ('init', 'config', 'commandline', 'run'):
|
||||
raise ValueError, "invalid value for 'stop_after': %s" % `stop_after`
|
||||
raise ValueError, "invalid value for 'stop_after': %r" % (stop_after,)
|
||||
|
||||
global _setup_stop_after, _setup_distribution
|
||||
_setup_stop_after = stop_after
|
||||
|
|
|
@ -33,7 +33,7 @@ def mkpath (name, mode=0777, verbose=0, dry_run=0):
|
|||
# Detect a common bug -- name is None
|
||||
if type(name) is not StringType:
|
||||
raise DistutilsInternalError, \
|
||||
"mkpath: 'name' must be a string (got %s)" % `name`
|
||||
"mkpath: 'name' must be a string (got %r)" % (name,)
|
||||
|
||||
# XXX what's the better way to handle verbosity? print as we create
|
||||
# each directory in the path (the current behaviour), or only announce
|
||||
|
|
|
@ -525,9 +525,9 @@ class Distribution:
|
|||
func()
|
||||
else:
|
||||
raise DistutilsClassError(
|
||||
"invalid help function %s for help option '%s': "
|
||||
"invalid help function %r for help option '%s': "
|
||||
"must be a callable object (function, etc.)"
|
||||
% (`func`, help_option))
|
||||
% (func, help_option))
|
||||
|
||||
if help_option_found:
|
||||
return
|
||||
|
|
|
@ -162,7 +162,7 @@ class FancyGetopt:
|
|||
else:
|
||||
# the option table is part of the code, so simply
|
||||
# assert that it is correct
|
||||
assert "invalid option tuple: %s" % `option`
|
||||
assert "invalid option tuple: %r" % (option,)
|
||||
|
||||
# Type- and value-check the option names
|
||||
if type(long) is not StringType or len(long) < 2:
|
||||
|
|
|
@ -285,7 +285,7 @@ def execute (func, args, msg=None, verbose=0, dry_run=0):
|
|||
print.
|
||||
"""
|
||||
if msg is None:
|
||||
msg = "%s%s" % (func.__name__, `args`)
|
||||
msg = "%s%r" % (func.__name__, args)
|
||||
if msg[-2:] == ',)': # correct for singleton tuple
|
||||
msg = msg[0:-2] + ')'
|
||||
|
||||
|
@ -307,7 +307,7 @@ def strtobool (val):
|
|||
elif val in ('n', 'no', 'f', 'false', 'off', '0'):
|
||||
return 0
|
||||
else:
|
||||
raise ValueError, "invalid truth value %s" % `val`
|
||||
raise ValueError, "invalid truth value %r" % (val,)
|
||||
|
||||
|
||||
def byte_compile (py_files,
|
||||
|
@ -394,11 +394,11 @@ files = [
|
|||
|
||||
script.write(string.join(map(repr, py_files), ",\n") + "]\n")
|
||||
script.write("""
|
||||
byte_compile(files, optimize=%s, force=%s,
|
||||
prefix=%s, base_dir=%s,
|
||||
verbose=%s, dry_run=0,
|
||||
byte_compile(files, optimize=%r, force=%r,
|
||||
prefix=%r, base_dir=%r,
|
||||
verbose=%r, dry_run=0,
|
||||
direct=1)
|
||||
""" % (`optimize`, `force`, `prefix`, `base_dir`, `verbose`))
|
||||
""" % (optimize, force, prefix, base_dir, verbose))
|
||||
|
||||
script.close()
|
||||
|
||||
|
@ -432,8 +432,8 @@ byte_compile(files, optimize=%s, force=%s,
|
|||
if prefix:
|
||||
if file[:len(prefix)] != prefix:
|
||||
raise ValueError, \
|
||||
("invalid prefix: filename %s doesn't start with %s"
|
||||
% (`file`, `prefix`))
|
||||
("invalid prefix: filename %r doesn't start with %r"
|
||||
% (file, prefix))
|
||||
dfile = dfile[len(prefix):]
|
||||
if base_dir:
|
||||
dfile = os.path.join(base_dir, dfile)
|
||||
|
|
|
@ -334,8 +334,8 @@ def _extract_examples(s):
|
|||
continue
|
||||
lineno = i - 1
|
||||
if line[j] != " ":
|
||||
raise ValueError("line " + `lineno` + " of docstring lacks "
|
||||
"blank after " + PS1 + ": " + line)
|
||||
raise ValueError("line %r of docstring lacks blank after %s: %s" %
|
||||
(lineno, PS1, line))
|
||||
j = j + 1
|
||||
blanks = m.group(1)
|
||||
nblanks = len(blanks)
|
||||
|
@ -348,7 +348,7 @@ def _extract_examples(s):
|
|||
if m:
|
||||
if m.group(1) != blanks:
|
||||
raise ValueError("inconsistent leading whitespace "
|
||||
"in line " + `i` + " of docstring: " + line)
|
||||
"in line %r of docstring: %s" % (i, line))
|
||||
i = i + 1
|
||||
else:
|
||||
break
|
||||
|
@ -367,7 +367,7 @@ def _extract_examples(s):
|
|||
while 1:
|
||||
if line[:nblanks] != blanks:
|
||||
raise ValueError("inconsistent leading whitespace "
|
||||
"in line " + `i` + " of docstring: " + line)
|
||||
"in line %r of docstring: %s" % (i, line))
|
||||
expect.append(line[nblanks:])
|
||||
i = i + 1
|
||||
line = lines[i]
|
||||
|
@ -475,7 +475,7 @@ def _run_examples_inner(out, fakeout, examples, globs, verbose, name,
|
|||
failures = failures + 1
|
||||
out("*" * 65 + "\n")
|
||||
_tag_out(out, ("Failure in example", source))
|
||||
out("from line #" + `lineno` + " of " + name + "\n")
|
||||
out("from line #%r of %s\n" % (lineno, name))
|
||||
if state == FAIL:
|
||||
_tag_out(out, ("Expected", want or NADA), ("Got", got))
|
||||
else:
|
||||
|
@ -686,8 +686,7 @@ See doctest.testmod docs for the meaning of optionflags.
|
|||
if mod is None and globs is None:
|
||||
raise TypeError("Tester.__init__: must specify mod or globs")
|
||||
if mod is not None and not _ismodule(mod):
|
||||
raise TypeError("Tester.__init__: mod must be a module; " +
|
||||
`mod`)
|
||||
raise TypeError("Tester.__init__: mod must be a module; %r" % (mod,))
|
||||
if globs is None:
|
||||
globs = mod.__dict__
|
||||
self.globs = globs
|
||||
|
@ -775,7 +774,7 @@ See doctest.testmod docs for the meaning of optionflags.
|
|||
name = object.__name__
|
||||
except AttributeError:
|
||||
raise ValueError("Tester.rundoc: name must be given "
|
||||
"when object.__name__ doesn't exist; " + `object`)
|
||||
"when object.__name__ doesn't exist; %r" % (object,))
|
||||
if self.verbose:
|
||||
print "Running", name + ".__doc__"
|
||||
f, t = run_docstring_examples(object, self.globs, self.verbose, name,
|
||||
|
@ -893,8 +892,7 @@ See doctest.testmod docs for the meaning of optionflags.
|
|||
"""
|
||||
|
||||
if not hasattr(d, "items"):
|
||||
raise TypeError("Tester.rundict: d must support .items(); " +
|
||||
`d`)
|
||||
raise TypeError("Tester.rundict: d must support .items(); %r" % (d,))
|
||||
f = t = 0
|
||||
# Run the tests by alpha order of names, for consistency in
|
||||
# verbose-mode output.
|
||||
|
@ -936,7 +934,7 @@ See doctest.testmod docs for the meaning of optionflags.
|
|||
else:
|
||||
raise TypeError("Tester.run__test__: values in "
|
||||
"dict must be strings, functions, methods, "
|
||||
"or classes; " + `v`)
|
||||
"or classes; %r" % (v,))
|
||||
failures = failures + f
|
||||
tries = tries + t
|
||||
finally:
|
||||
|
@ -1139,7 +1137,7 @@ def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None,
|
|||
m = sys.modules.get('__main__')
|
||||
|
||||
if not _ismodule(m):
|
||||
raise TypeError("testmod: module required; " + `m`)
|
||||
raise TypeError("testmod: module required; %r" % (m,))
|
||||
if name is None:
|
||||
name = m.__name__
|
||||
tester = Tester(m, globs=globs, verbose=verbose, isprivate=isprivate,
|
||||
|
@ -1153,7 +1151,7 @@ def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None,
|
|||
if testdict:
|
||||
if not hasattr(testdict, "items"):
|
||||
raise TypeError("testmod: module.__test__ must support "
|
||||
".items(); " + `testdict`)
|
||||
".items(); %r" % (testdict,))
|
||||
f, t = tester.run__test__(testdict, name + ".__test__")
|
||||
failures += f
|
||||
tries += t
|
||||
|
|
|
@ -325,22 +325,22 @@ class AbstractWriter(NullWriter):
|
|||
"""
|
||||
|
||||
def new_alignment(self, align):
|
||||
print "new_alignment(%s)" % `align`
|
||||
print "new_alignment(%r)" % (align,)
|
||||
|
||||
def new_font(self, font):
|
||||
print "new_font(%s)" % `font`
|
||||
print "new_font(%r)" % (font,)
|
||||
|
||||
def new_margin(self, margin, level):
|
||||
print "new_margin(%s, %d)" % (`margin`, level)
|
||||
print "new_margin(%r, %d)" % (margin, level)
|
||||
|
||||
def new_spacing(self, spacing):
|
||||
print "new_spacing(%s)" % `spacing`
|
||||
print "new_spacing(%r)" % (spacing,)
|
||||
|
||||
def new_styles(self, styles):
|
||||
print "new_styles(%s)" % `styles`
|
||||
print "new_styles(%r)" % (styles,)
|
||||
|
||||
def send_paragraph(self, blankline):
|
||||
print "send_paragraph(%s)" % `blankline`
|
||||
print "send_paragraph(%r)" % (blankline,)
|
||||
|
||||
def send_line_break(self):
|
||||
print "send_line_break()"
|
||||
|
@ -349,13 +349,13 @@ class AbstractWriter(NullWriter):
|
|||
print "send_hor_rule()"
|
||||
|
||||
def send_label_data(self, data):
|
||||
print "send_label_data(%s)" % `data`
|
||||
print "send_label_data(%r)" % (data,)
|
||||
|
||||
def send_flowing_data(self, data):
|
||||
print "send_flowing_data(%s)" % `data`
|
||||
print "send_flowing_data(%r)" % (data,)
|
||||
|
||||
def send_literal_data(self, data):
|
||||
print "send_literal_data(%s)" % `data`
|
||||
print "send_literal_data(%r)" % (data,)
|
||||
|
||||
|
||||
class DumbWriter(NullWriter):
|
||||
|
|
|
@ -88,7 +88,7 @@ def fix(x, digs):
|
|||
"""Format x as [-]ddd.ddd with 'digs' digits after the point
|
||||
and at least one digit before.
|
||||
If digs <= 0, the point is suppressed."""
|
||||
if type(x) != type(''): x = `x`
|
||||
if type(x) != type(''): x = repr(x)
|
||||
try:
|
||||
sign, intpart, fraction, expo = extract(x)
|
||||
except NotANumber:
|
||||
|
@ -104,7 +104,7 @@ def sci(x, digs):
|
|||
"""Format x as [-]d.dddE[+-]ddd with 'digs' digits after the point
|
||||
and exactly one digit before.
|
||||
If digs is <= 0, one digit is kept and the point is suppressed."""
|
||||
if type(x) != type(''): x = `x`
|
||||
if type(x) != type(''): x = repr(x)
|
||||
sign, intpart, fraction, expo = extract(x)
|
||||
if not intpart:
|
||||
while fraction and fraction[0] == '0':
|
||||
|
@ -126,7 +126,7 @@ def sci(x, digs):
|
|||
expo + len(intpart) - 1
|
||||
s = sign + intpart
|
||||
if digs > 0: s = s + '.' + fraction
|
||||
e = `abs(expo)`
|
||||
e = repr(abs(expo))
|
||||
e = '0'*(3-len(e)) + e
|
||||
if expo < 0: e = '-' + e
|
||||
else: e = '+' + e
|
||||
|
|
|
@ -161,7 +161,7 @@ class FTP:
|
|||
while i > 5 and s[i-1] in '\r\n':
|
||||
i = i-1
|
||||
s = s[:5] + '*'*(i-5) + s[i:]
|
||||
return `s`
|
||||
return repr(s)
|
||||
|
||||
# Internal: send one line to the server, appending CRLF
|
||||
def putline(self, line):
|
||||
|
@ -250,7 +250,7 @@ class FTP:
|
|||
port number.
|
||||
'''
|
||||
hbytes = host.split('.')
|
||||
pbytes = [`port/256`, `port%256`]
|
||||
pbytes = [repr(port/256), repr(port%256)]
|
||||
bytes = hbytes + pbytes
|
||||
cmd = 'PORT ' + ','.join(bytes)
|
||||
return self.voidcmd(cmd)
|
||||
|
@ -264,7 +264,7 @@ class FTP:
|
|||
af = 2
|
||||
if af == 0:
|
||||
raise error_proto, 'unsupported address family'
|
||||
fields = ['', `af`, host, `port`, '']
|
||||
fields = ['', repr(af), host, repr(port), '']
|
||||
cmd = 'EPRT ' + '|'.join(fields)
|
||||
return self.voidcmd(cmd)
|
||||
|
||||
|
@ -397,7 +397,7 @@ class FTP:
|
|||
fp = conn.makefile('rb')
|
||||
while 1:
|
||||
line = fp.readline()
|
||||
if self.debugging > 2: print '*retr*', `line`
|
||||
if self.debugging > 2: print '*retr*', repr(line)
|
||||
if not line:
|
||||
break
|
||||
if line[-2:] == CRLF:
|
||||
|
|
|
@ -47,7 +47,7 @@ def type_to_name(gtype):
|
|||
_type_to_name_map[eval(name)] = name[2:]
|
||||
if gtype in _type_to_name_map:
|
||||
return _type_to_name_map[gtype]
|
||||
return 'TYPE=' + `gtype`
|
||||
return 'TYPE=%r' % (gtype,)
|
||||
|
||||
# Names for characters and strings
|
||||
CRLF = '\r\n'
|
||||
|
@ -113,7 +113,7 @@ def get_directory(f):
|
|||
gtype = line[0]
|
||||
parts = line[1:].split(TAB)
|
||||
if len(parts) < 4:
|
||||
print '(Bad line from server:', `line`, ')'
|
||||
print '(Bad line from server: %r)' % (line,)
|
||||
continue
|
||||
if len(parts) > 4:
|
||||
if parts[4:] != ['+']:
|
||||
|
@ -198,7 +198,7 @@ def test():
|
|||
for item in entries: print item
|
||||
else:
|
||||
data = get_binary(f)
|
||||
print 'binary data:', len(data), 'bytes:', `data[:100]`[:40]
|
||||
print 'binary data:', len(data), 'bytes:', repr(data[:100])[:40]
|
||||
|
||||
# Run the test when run as script
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -442,7 +442,7 @@ def _test():
|
|||
g = sys.stdout
|
||||
else:
|
||||
if arg[-3:] != ".gz":
|
||||
print "filename doesn't end in .gz:", `arg`
|
||||
print "filename doesn't end in .gz:", repr(arg)
|
||||
continue
|
||||
f = open(arg, "rb")
|
||||
g = __builtin__.open(arg[:-3], "wb")
|
||||
|
|
|
@ -182,7 +182,7 @@ class ColorDelegator(Delegator):
|
|||
lines_to_get = min(lines_to_get * 2, 100)
|
||||
ok = "SYNC" in self.tag_names(next + "-1c")
|
||||
line = self.get(mark, next)
|
||||
##print head, "get", mark, next, "->", `line`
|
||||
##print head, "get", mark, next, "->", repr(line)
|
||||
if not line:
|
||||
return
|
||||
for tag in self.tagdefs.keys():
|
||||
|
|
|
@ -761,7 +761,7 @@ class EditorWindow:
|
|||
try:
|
||||
self.load_extension(name)
|
||||
except:
|
||||
print "Failed to load extension", `name`
|
||||
print "Failed to load extension", repr(name)
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
|
@ -937,7 +937,7 @@ class EditorWindow:
|
|||
elif key == 'context_use_ps1':
|
||||
self.context_use_ps1 = value
|
||||
else:
|
||||
raise KeyError, "bad option name: %s" % `key`
|
||||
raise KeyError, "bad option name: %r" % (key,)
|
||||
|
||||
# If ispythonsource and guess are true, guess a good value for
|
||||
# indentwidth based on file content (if possible), and if
|
||||
|
@ -1071,7 +1071,7 @@ class EditorWindow:
|
|||
y = PyParse.Parser(self.indentwidth, self.tabwidth)
|
||||
for context in self.num_context_lines:
|
||||
startat = max(lno - context, 1)
|
||||
startatindex = `startat` + ".0"
|
||||
startatindex = repr(startat) + ".0"
|
||||
rawtext = text.get(startatindex, "insert")
|
||||
y.set_str(rawtext)
|
||||
bod = y.find_good_parse_start(
|
||||
|
@ -1103,7 +1103,7 @@ class EditorWindow:
|
|||
else:
|
||||
self.reindent_to(y.compute_backslash_indent())
|
||||
else:
|
||||
assert 0, "bogus continuation type " + `c`
|
||||
assert 0, "bogus continuation type %r" % (c,)
|
||||
return "break"
|
||||
|
||||
# This line starts a brand new stmt; indent relative to
|
||||
|
@ -1333,7 +1333,7 @@ class IndentSearcher:
|
|||
if self.finished:
|
||||
return ""
|
||||
i = self.i = self.i + 1
|
||||
mark = `i` + ".0"
|
||||
mark = repr(i) + ".0"
|
||||
if self.text.compare(mark, ">=", "end"):
|
||||
return ""
|
||||
return self.text.get(mark, mark + " lineend+1c")
|
||||
|
|
|
@ -35,7 +35,7 @@ class FileList:
|
|||
if os.path.isdir(filename):
|
||||
tkMessageBox.showerror(
|
||||
"Is A Directory",
|
||||
"The path %s is a directory." % `filename`,
|
||||
"The path %r is a directory." % (filename,),
|
||||
master=self.root)
|
||||
return None
|
||||
key = os.path.normcase(filename)
|
||||
|
@ -46,7 +46,7 @@ class FileList:
|
|||
if not os.path.exists(filename):
|
||||
tkMessageBox.showinfo(
|
||||
"New File",
|
||||
"Opening non-existent file %s" % `filename`,
|
||||
"Opening non-existent file %r" % (filename,),
|
||||
master=self.root)
|
||||
if action is None:
|
||||
return self.EditorWindow(self, filename, key)
|
||||
|
@ -102,7 +102,7 @@ class FileList:
|
|||
self.inversedict[conflict] = None
|
||||
tkMessageBox.showerror(
|
||||
"Name Conflict",
|
||||
"You now have multiple edit windows open for %s" % `filename`,
|
||||
"You now have multiple edit windows open for %r" % (filename,),
|
||||
master=self.root)
|
||||
self.dict[newkey] = edit
|
||||
self.inversedict[edit] = newkey
|
||||
|
|
|
@ -77,7 +77,7 @@ class GrepDialog(SearchDialogBase):
|
|||
list.sort()
|
||||
self.close()
|
||||
pat = self.engine.getpat()
|
||||
print "Searching %s in %s ..." % (`pat`, path)
|
||||
print "Searching %r in %s ..." % (pat, path)
|
||||
hits = 0
|
||||
for fn in list:
|
||||
try:
|
||||
|
|
|
@ -97,7 +97,7 @@ class SequenceTreeItem(ObjectTreeItem):
|
|||
continue
|
||||
def setfunction(value, key=key, object=self.object):
|
||||
object[key] = value
|
||||
item = make_objecttreeitem(`key` + ":", value, setfunction)
|
||||
item = make_objecttreeitem("%r:" % (key,), value, setfunction)
|
||||
sublist.append(item)
|
||||
return sublist
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ class LastOpenBracketFinder:
|
|||
y = PyParse.Parser(self.indentwidth, self.tabwidth)
|
||||
for context in self.num_context_lines:
|
||||
startat = max(lno - context, 1)
|
||||
startatindex = `startat` + ".0"
|
||||
startatindex = repr(startat) + ".0"
|
||||
# rawtext needs to contain everything up to the last
|
||||
# character, which was the close paren. the parser also
|
||||
# requires that the last line ends with "\n"
|
||||
|
|
|
@ -335,9 +335,9 @@ class ModifiedInterpreter(InteractiveInterpreter):
|
|||
del_exitf = idleConf.GetOption('main', 'General', 'delete-exitfunc',
|
||||
default=False, type='bool')
|
||||
if __name__ == 'idlelib.PyShell':
|
||||
command = "__import__('idlelib.run').run.main(" + `del_exitf` +")"
|
||||
command = "__import__('idlelib.run').run.main(%r)" % (del_exitf,)
|
||||
else:
|
||||
command = "__import__('run').main(" + `del_exitf` + ")"
|
||||
command = "__import__('run').main(%r)" % (del_exitf,)
|
||||
if sys.platform[:3] == 'win' and ' ' in sys.executable:
|
||||
# handle embedded space in path by quoting the argument
|
||||
decorated_exec = '"%s"' % sys.executable
|
||||
|
@ -454,12 +454,12 @@ class ModifiedInterpreter(InteractiveInterpreter):
|
|||
def transfer_path(self):
|
||||
self.runcommand("""if 1:
|
||||
import sys as _sys
|
||||
_sys.path = %s
|
||||
_sys.path = %r
|
||||
del _sys
|
||||
_msg = 'Use File/Exit or your end-of-file key to quit IDLE'
|
||||
__builtins__.quit = __builtins__.exit = _msg
|
||||
del _msg
|
||||
\n""" % `sys.path`)
|
||||
\n""" % (sys.path,))
|
||||
|
||||
active_seq = None
|
||||
|
||||
|
@ -483,7 +483,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
|
|||
console = self.tkconsole.console
|
||||
if how == "OK":
|
||||
if what is not None:
|
||||
print >>console, `what`
|
||||
print >>console, repr(what)
|
||||
elif how == "EXCEPTION":
|
||||
if self.tkconsole.getvar("<<toggle-jit-stack-viewer>>"):
|
||||
self.remote_stack_viewer()
|
||||
|
@ -589,14 +589,14 @@ class ModifiedInterpreter(InteractiveInterpreter):
|
|||
def prepend_syspath(self, filename):
|
||||
"Prepend sys.path with file's directory if not already included"
|
||||
self.runcommand("""if 1:
|
||||
_filename = %s
|
||||
_filename = %r
|
||||
import sys as _sys
|
||||
from os.path import dirname as _dirname
|
||||
_dir = _dirname(_filename)
|
||||
if not _dir in _sys.path:
|
||||
_sys.path.insert(0, _dir)
|
||||
del _filename, _sys, _dirname, _dir
|
||||
\n""" % `filename`)
|
||||
\n""" % (filename,))
|
||||
|
||||
def showsyntaxerror(self, filename=None):
|
||||
"""Extend base class method: Add Colorizing
|
||||
|
@ -1333,9 +1333,9 @@ def main():
|
|||
if shell and cmd or script:
|
||||
shell.interp.runcommand("""if 1:
|
||||
import sys as _sys
|
||||
_sys.argv = %s
|
||||
_sys.argv = %r
|
||||
del _sys
|
||||
\n""" % `sys.argv`)
|
||||
\n""" % (sys.argv,))
|
||||
if cmd:
|
||||
shell.interp.execsource(cmd)
|
||||
elif script:
|
||||
|
|
|
@ -94,7 +94,7 @@ class IdbAdapter:
|
|||
self.idb.set_return(frame)
|
||||
|
||||
def get_stack(self, fid, tbid):
|
||||
##print >>sys.__stderr__, "get_stack(%s, %s)" % (`fid`, `tbid`)
|
||||
##print >>sys.__stderr__, "get_stack(%r, %r)" % (fid, tbid)
|
||||
frame = frametable[fid]
|
||||
if tbid is None:
|
||||
tb = None
|
||||
|
@ -295,7 +295,7 @@ class IdbProxy:
|
|||
def call(self, methodname, *args, **kwargs):
|
||||
##print "**IdbProxy.call %s %s %s" % (methodname, args, kwargs)
|
||||
value = self.conn.remotecall(self.oid, methodname, args, kwargs)
|
||||
##print "**IdbProxy.call %s returns %s" % (methodname, `value`)
|
||||
##print "**IdbProxy.call %s returns %r" % (methodname, value)
|
||||
return value
|
||||
|
||||
def run(self, cmd, locals):
|
||||
|
|
|
@ -145,16 +145,16 @@ class ScriptBinding:
|
|||
dirname = os.path.dirname(filename)
|
||||
# XXX Too often this discards arguments the user just set...
|
||||
interp.runcommand("""if 1:
|
||||
_filename = %s
|
||||
_filename = %r
|
||||
import sys as _sys
|
||||
from os.path import basename as _basename
|
||||
if (not _sys.argv or
|
||||
_basename(_sys.argv[0]) != _basename(_filename)):
|
||||
_sys.argv = [_filename]
|
||||
import os as _os
|
||||
_os.chdir(%s)
|
||||
_os.chdir(%r)
|
||||
del _filename, _sys, _basename, _os
|
||||
\n""" % (`filename`, `dirname`))
|
||||
\n""" % (filename, dirname))
|
||||
interp.prepend_syspath(filename)
|
||||
interp.runcode(code)
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ except NameError:
|
|||
if os.path.isdir(_icondir):
|
||||
ICONDIR = _icondir
|
||||
elif not os.path.isdir(ICONDIR):
|
||||
raise RuntimeError, "can't find icon directory (%s)" % `ICONDIR`
|
||||
raise RuntimeError, "can't find icon directory (%r)" % (ICONDIR,)
|
||||
|
||||
def listicons(icondir=ICONDIR):
|
||||
"""Utility to display the available icons."""
|
||||
|
|
|
@ -177,7 +177,7 @@ class Command:
|
|||
t = (self.index1, self.index2, self.chars, self.tags)
|
||||
if self.tags is None:
|
||||
t = t[:-1]
|
||||
return s + `t`
|
||||
return s + repr(t)
|
||||
|
||||
def do(self, text):
|
||||
pass
|
||||
|
@ -310,7 +310,7 @@ class CommandSequence(Command):
|
|||
s = self.__class__.__name__
|
||||
strs = []
|
||||
for cmd in self.cmds:
|
||||
strs.append(" " + `cmd`)
|
||||
strs.append(" %r" % (cmd,))
|
||||
return s + "(\n" + ",\n".join(strs) + "\n)"
|
||||
|
||||
def __len__(self):
|
||||
|
|
|
@ -69,7 +69,7 @@ class OriginalCommand:
|
|||
self.orig_and_name = (self.orig, self.name)
|
||||
|
||||
def __repr__(self):
|
||||
return "OriginalCommand(%s, %s)" % (`self.redir`, `self.name`)
|
||||
return "OriginalCommand(%r, %r)" % (self.redir, self.name)
|
||||
|
||||
def __call__(self, *args):
|
||||
return self.tk_call(self.orig_and_name + args)
|
||||
|
|
|
@ -66,7 +66,7 @@ class AboutDialog(Toplevel):
|
|||
sys.version.split()[0], fg=self.fg, bg=self.bg)
|
||||
labelPythonVer.grid(row=9, column=0, sticky=W, padx=10, pady=0)
|
||||
# handle weird tk version num in windoze python >= 1.6 (?!?)
|
||||
tkVer = `TkVersion`.split('.')
|
||||
tkVer = repr(TkVersion).split('.')
|
||||
tkVer[len(tkVer)-1] = str('%.3g' % (float('.'+tkVer[len(tkVer)-1])))[2:]
|
||||
if tkVer[len(tkVer)-1] == '':
|
||||
tkVer[len(tkVer)-1] = '0'
|
||||
|
@ -141,8 +141,7 @@ class AboutDialog(Toplevel):
|
|||
except IOError:
|
||||
import tkMessageBox
|
||||
tkMessageBox.showerror(title='File Load Error',
|
||||
message='Unable to load file '+
|
||||
`fn`+' .',
|
||||
message='Unable to load file %r .' % (fn,),
|
||||
parent=self)
|
||||
return
|
||||
else:
|
||||
|
|
|
@ -718,7 +718,7 @@ class ConfigDialog(Toplevel):
|
|||
def DeleteCustomKeys(self):
|
||||
keySetName=self.customKeys.get()
|
||||
if not tkMessageBox.askyesno('Delete Key Set','Are you sure you wish '+
|
||||
'to delete the key set '+`keySetName`+' ?',
|
||||
'to delete the key set %r ?' % (keySetName),
|
||||
parent=self):
|
||||
return
|
||||
#remove key set from config
|
||||
|
@ -745,7 +745,7 @@ class ConfigDialog(Toplevel):
|
|||
def DeleteCustomTheme(self):
|
||||
themeName=self.customTheme.get()
|
||||
if not tkMessageBox.askyesno('Delete Theme','Are you sure you wish '+
|
||||
'to delete the theme '+`themeName`+' ?',
|
||||
'to delete the theme %r ?' % (themeName,),
|
||||
parent=self):
|
||||
return
|
||||
#remove theme from config
|
||||
|
|
|
@ -231,10 +231,11 @@ class IdleConf:
|
|||
elif self.defaultCfg[configType].has_option(section,option):
|
||||
return self.defaultCfg[configType].Get(section, option, type=type)
|
||||
else: #returning default, print warning
|
||||
warning=('\n Warning: configHandler.py - IdleConf.GetOption -\n'+
|
||||
' problem retrieving configration option '+`option`+'\n'+
|
||||
' from section '+`section`+'.\n'+
|
||||
' returning default value: '+`default`+'\n')
|
||||
warning=('\n Warning: configHandler.py - IdleConf.GetOption -\n'
|
||||
' problem retrieving configration option %r\n'
|
||||
' from section %r.\n'
|
||||
' returning default value: %r\n' %
|
||||
(option, section, default))
|
||||
sys.stderr.write(warning)
|
||||
return default
|
||||
|
||||
|
@ -331,10 +332,11 @@ class IdleConf:
|
|||
for element in theme.keys():
|
||||
if not cfgParser.has_option(themeName,element):
|
||||
#we are going to return a default, print warning
|
||||
warning=('\n Warning: configHandler.py - IdleConf.GetThemeDict'+
|
||||
' -\n problem retrieving theme element '+`element`+
|
||||
'\n from theme '+`themeName`+'.\n'+
|
||||
' returning default value: '+`theme[element]`+'\n')
|
||||
warning=('\n Warning: configHandler.py - IdleConf.GetThemeDict'
|
||||
' -\n problem retrieving theme element %r'
|
||||
'\n from theme %r.\n'
|
||||
' returning default value: %r\n' %
|
||||
(element, themeName, theme[element]))
|
||||
sys.stderr.write(warning)
|
||||
colour=cfgParser.Get(themeName,element,default=theme[element])
|
||||
theme[element]=colour
|
||||
|
@ -561,10 +563,11 @@ class IdleConf:
|
|||
if binding:
|
||||
keyBindings[event]=binding
|
||||
else: #we are going to return a default, print warning
|
||||
warning=('\n Warning: configHandler.py - IdleConf.GetCoreKeys'+
|
||||
' -\n problem retrieving key binding for event '+
|
||||
`event`+'\n from key set '+`keySetName`+'.\n'+
|
||||
' returning default value: '+`keyBindings[event]`+'\n')
|
||||
warning=('\n Warning: configHandler.py - IdleConf.GetCoreKeys'
|
||||
' -\n problem retrieving key binding for event %r'
|
||||
'\n from key set %r.\n'
|
||||
' returning default value: %r\n' %
|
||||
(event, keySetName, keyBindings[event]))
|
||||
sys.stderr.write(warning)
|
||||
return keyBindings
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue