Replace backticks with repr() or "%r"

From SF patch #852334.
This commit is contained in:
Walter Dörwald 2004-02-12 17:35:32 +00:00
parent ecfeb7f095
commit 70a6b49821
246 changed files with 926 additions and 962 deletions

View file

@ -52,7 +52,7 @@ class ICONbrowse(FrameWork.Application):
def showICON(self, resid):
w = ICONwindow(self)
w.open(resid)
#EasyDialogs.Message('Show ICON '+`resid`)
#EasyDialogs.Message('Show ICON %r' % (resid,))
def findICONresources(self):
num = Res.CountResources('ICON')
@ -70,7 +70,7 @@ class ICONbrowse(FrameWork.Application):
class ICONwindow(FrameWork.Window):
def open(self, (resid, resname)):
if not resname:
resname = '#'+`resid`
resname = '#%r' % (resid,)
self.resid = resid
self.picture = Icn.GetIcon(self.resid)
l, t, r, b = 0, 0, 32, 32
@ -127,7 +127,7 @@ class MyDialog(FrameWork.DialogWindow):
if self.contents:
self.list.LAddRow(len(self.contents), 0)
for i in range(len(self.contents)):
v = `self.contents[i][0]`
v = repr(self.contents[i][0])
if self.contents[i][1]:
v = v + '"' + self.contents[i][1] + '"'
self.list.LSetCell(v, (0, i))

View file

@ -47,7 +47,7 @@ class PICTbrowse(FrameWork.Application):
def showPICT(self, resid):
w = PICTwindow(self)
w.open(resid)
#EasyDialogs.Message('Show PICT '+`resid`)
#EasyDialogs.Message('Show PICT %r' % (resid,))
def findPICTresources(self):
num = Res.CountResources('PICT')
@ -65,11 +65,11 @@ class PICTbrowse(FrameWork.Application):
class PICTwindow(FrameWork.Window):
def open(self, (resid, resname)):
if not resname:
resname = '#'+`resid`
resname = '#%r' % (resid,)
self.resid = resid
picture = Qd.GetPicture(self.resid)
# Get rect for picture
print `picture.data[:16]`
print repr(picture.data[:16])
sz, t, l, b, r = struct.unpack('hhhhh', picture.data[:10])
print 'pict:', t, l, b, r
width = r-l
@ -105,7 +105,7 @@ class MyDialog(FrameWork.DialogWindow):
if self.contents:
self.list.LAddRow(len(self.contents), 0)
for i in range(len(self.contents)):
v = `self.contents[i][0]`
v = repr(self.contents[i][0])
if self.contents[i][1]:
v = v + '"' + self.contents[i][1] + '"'
self.list.LSetCell(v, (0, i))

View file

@ -51,7 +51,7 @@ class PICTbrowse(FrameWork.Application):
def showPICT(self, resid):
w = PICTwindow(self)
w.open(resid)
#EasyDialogs.Message('Show PICT '+`resid`)
#EasyDialogs.Message('Show PICT %r' % (resid,))
def findPICTresources(self):
num = Res.CountResources('PICT')
@ -69,7 +69,7 @@ class PICTbrowse(FrameWork.Application):
class PICTwindow(FrameWork.Window):
def open(self, (resid, resname)):
if not resname:
resname = '#'+`resid`
resname = '#%r' % (resid,)
self.resid = resid
self.picture = Qd.GetPicture(self.resid)
# Get rect for picture
@ -127,7 +127,7 @@ class MyDialog(FrameWork.DialogWindow):
if self.contents:
self.list.LAddRow(len(self.contents), 0)
for i in range(len(self.contents)):
v = `self.contents[i][0]`
v = repr(self.contents[i][0])
if self.contents[i][1]:
v = v + '"' + self.contents[i][1] + '"'
self.list.LSetCell(v, (0, i))

View file

@ -52,7 +52,7 @@ class CIconbrowse(FrameWork.Application):
def showCIcon(self, resid):
w = CIconwindow(self)
w.open(resid)
#EasyDialogs.Message('Show cicn '+`resid`)
#EasyDialogs.Message('Show cicn %r' % (resid,))
def findcicnresources(self):
num = Res.CountResources('cicn')
@ -70,7 +70,7 @@ class CIconbrowse(FrameWork.Application):
class CIconwindow(FrameWork.Window):
def open(self, (resid, resname)):
if not resname:
resname = '#'+`resid`
resname = '#%r' % (resid,)
self.resid = resid
self.picture = Icn.GetCIcon(self.resid)
l, t, r, b = 0, 0, 32, 32
@ -127,7 +127,7 @@ class MyDialog(FrameWork.DialogWindow):
if self.contents:
self.list.LAddRow(len(self.contents), 0)
for i in range(len(self.contents)):
v = `self.contents[i][0]`
v = repr(self.contents[i][0])
if self.contents[i][1]:
v = v + '"' + self.contents[i][1] + '"'
self.list.LSetCell(v, (0, i))

View file

@ -46,7 +46,7 @@ class PICTbrowse(FrameWork.Application):
def showPICT(self, resid):
w = PICTwindow(self)
w.open(resid)
#EasyDialogs.Message('Show PICT '+`resid`)
#EasyDialogs.Message('Show PICT %r' % (resid,))
def findPICTresources(self):
num = Res.CountResources('PICT')
@ -64,11 +64,11 @@ class PICTbrowse(FrameWork.Application):
class PICTwindow(FrameWork.Window):
def open(self, (resid, resname)):
if not resname:
resname = '#'+`resid`
resname = '#%r' % (resid,)
self.resid = resid
picture = Qd.GetPicture(self.resid)
# Get rect for picture
print `picture.data[:16]`
print repr(picture.data[:16])
sz, t, l, b, r = struct.unpack('hhhhh', picture.data[:10])
print 'pict:', t, l, b, r
width = r-l
@ -104,7 +104,7 @@ class MyDialog(FrameWork.DialogWindow):
if self.contents:
self.list.LAddRow(len(self.contents), 0)
for i in range(len(self.contents)):
v = `self.contents[i][0]`
v = repr(self.contents[i][0])
if self.contents[i][1]:
v = v + '"' + self.contents[i][1] + '"'
self.list.LSetCell(v, (0, i))

View file

@ -99,7 +99,7 @@ rv = cdll_N_pp('pascal string')
if rv == 'Was: pascal string':
print 'ok.'
else:
print 'Failed, returned', `rv`
print 'Failed, returned', repr(rv)
print 'Test cdll_N_bb'
rv = cdll_N_bb(-100)
@ -128,5 +128,5 @@ rv = cdll_N_sH('new data', h)
if rv == None and h.data == 'new data':
print 'ok.'
else:
print 'Failed, rv is', rv, 'and handle data is', `rv.data`
print 'Failed, rv is', rv, 'and handle data is', repr(rv.data)
sys.exit(1)

View file

@ -53,7 +53,7 @@ class imgbrowse(FrameWork.Application):
try:
rdr = img.reader(imgformat.macrgb16, pathname)
except img.error, arg:
EasyDialogs.Message(`arg`)
EasyDialogs.Message(repr(arg))
return
w, h = rdr.width, rdr.height
bar.set(10)

View file

@ -276,7 +276,7 @@ class Mlted(Application):
data = fp.read()
fp.close()
except IOError, arg:
EasyDialogs.Message("IOERROR: "+`arg`)
EasyDialogs.Message("IOERROR: %r" % (arg,))
return
else:
path = None

View file

@ -7,7 +7,7 @@ def list1resources():
ntypes = Res.Count1Types()
for itype in range(1, 1+ntypes):
type = Res.Get1IndType(itype)
print "Type:", `type`
print "Type:", repr(type)
nresources = Res.Count1Resources(type)
for i in range(1, 1 + nresources):
Res.SetResLoad(0)
@ -19,7 +19,7 @@ def listresources():
ntypes = Res.CountTypes()
for itype in range(1, 1+ntypes):
type = Res.GetIndType(itype)
print "Type:", `type`
print "Type:", repr(type)
nresources = Res.CountResources(type)
for i in range(1, 1 + nresources):
Res.SetResLoad(0)

View file

@ -274,7 +274,7 @@ class Ped(Application):
data = fp.read()
fp.close()
except IOError, arg:
EasyDialogs.Message("IOERROR: "+`arg`)
EasyDialogs.Message("IOERROR: %r" % (arg,))
return
else:
path = None

View file

@ -516,7 +516,7 @@ class Wed(Application):
self.sizemenu = Menu(self.menubar, "Size")
self.sizeitems = []
for n in SIZES:
m = MenuItem(self.sizemenu, `n`, "", self.selsize)
m = MenuItem(self.sizemenu, repr(n), "", self.selsize)
self.sizeitems.append(m)
self.sizemenu.addseparator()
self.sizeitem_bigger = MenuItem(self.sizemenu, "Bigger", "+",
@ -670,7 +670,7 @@ class Wed(Application):
data = fp.read()
fp.close()
except IOError, arg:
EasyDialogs.Message("IOERROR: "+`arg`)
EasyDialogs.Message("IOERROR: %r" % (arg,))
return
else:
path = None
@ -688,7 +688,7 @@ class Wed(Application):
try:
fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line
except IOError, arg:
EasyDialogs.Message("IOERROR: "+`arg`)
EasyDialogs.Message("IOERROR: %r" % (args,))
return
self.active.menu_insert(fp)
else:
@ -702,7 +702,7 @@ class Wed(Application):
try:
fp = open(path, 'r')
except IOError, arg:
EasyDialogs.Message("IOERROR: "+`arg`)
EasyDialogs.Message("IOERROR: %r" % (arg,))
return
self.active.menu_insert_html(fp)
else:

View file

@ -375,7 +375,7 @@ class Wed(Application):
self.sizemenu = Menu(self.menubar, "Size")
self.sizeitems = []
for n in SIZES:
m = MenuItem(self.sizemenu, `n`, "", self.selsize)
m = MenuItem(self.sizemenu, repr(n), "", self.selsize)
self.sizeitems.append(m)
self.sizemenu.addseparator()
self.sizeitem_bigger = MenuItem(self.sizemenu, "Bigger", "+",
@ -529,7 +529,7 @@ class Wed(Application):
data = fp.read()
fp.close()
except IOError, arg:
EasyDialogs.Message("IOERROR: "+`arg`)
EasyDialogs.Message("IOERROR: %r" % (arg,))
return
else:
path = None

View file

@ -338,7 +338,7 @@ class Wed(Application):
data = fp.read()
fp.close()
except IOError, arg:
EasyDialogs.Message("IOERROR: "+`arg`)
EasyDialogs.Message("IOERROR: %r" % (arg,))
return
else:
path = None

View file

@ -4,7 +4,7 @@ import W
# key callback function
def tester(char, event):
text = `char` + "\r" + `ord(char)` + "\r" + hex(ord(char)) + "\r" + oct(ord(char))
text = "%r\r%d\r%s\r%s" % (char, ord(char), hex(ord(chart)), oct(ord(char)))
window.keys.set(text)
# close callback

View file

@ -79,7 +79,7 @@ window.open()
if 0:
import time
for i in range(20):
window.et2.set(`i`)
window.et2.set(repr(i))
#window.et2.SetPort()
#window.et2.draw()
time.sleep(0.1)

View file

@ -51,7 +51,7 @@ class _FontDialog:
self.lasttab, self.tabmode = tabsettings
self.w.tabsizetitle = W.TextBox((10, -26, leftmargin2, 14), "Tabsize:", TextEdit.teJustRight)
self.w.tabsizeedit = W.EditText((leftmargin, -29, 40, 20), "", self.checktab)
self.w.tabsizeedit.set(`self.lasttab`)
self.w.tabsizeedit.set(repr(self.lasttab))
radiobuttons = []
self.w.tabsizechars = W.RadioButton((leftmargin + 48, -26, 55, 14), "Spaces",
radiobuttons, self.toggletabmode)
@ -97,7 +97,7 @@ class _FontDialog:
else:
# convert spaces to pixels
self.lasttab = spacewidth * tabsize
self.w.tabsizeedit.set(`self.lasttab`)
self.w.tabsizeedit.set(repr(self.lasttab))
self.tabmode = tabmode
self.doit()
@ -139,7 +139,7 @@ class _FontDialog:
for i in range(1, len(_stylenames)):
if self.w[i].get():
style = style | 2 ** (i - 1)
#self.w.sample.set(`style`)
#self.w.sample.set(repr(style))
fontsettings, tabsettings = self.get()
self.w.sample.setfontsettings(fontsettings)
self.w.sample.settabsettings(tabsettings)
@ -161,7 +161,7 @@ class _FontDialog:
self.doit()
else:
SysBeep(0)
self.w.tabsizeedit.set(`self.lasttab`)
self.w.tabsizeedit.set(repr(self.lasttab))
self.w.tabsizeedit.selectall()
def checksize(self):
@ -181,7 +181,7 @@ class _FontDialog:
self.doit()
else:
SysBeep(0)
self.w.sizeedit.set(`self.lastsize`)
self.w.sizeedit.set(repr(self.lastsize))
self.w.sizeedit.selectall()
def doplain(self):

View file

@ -511,7 +511,7 @@ class Debugger(bdb.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
finally:
if hasattr(MacOS, 'EnableAppswitch'):

View file

@ -75,7 +75,7 @@ class Status:
def set(self, path, hits):
self.w.searching.set(path)
self.w.hits.set('Hits: ' + `hits`)
self.w.hits.set('Hits: %r' % (hits,))
app.breathe()
def close(self):

View file

@ -43,7 +43,7 @@ class Editor(W.Window):
if title:
self.title = title
else:
self.title = "Untitled Script " + `_scriptuntitledcounter`
self.title = "Untitled Script %r" % (_scriptuntitledcounter,)
_scriptuntitledcounter = _scriptuntitledcounter + 1
text = ""
self._creator = W._signature
@ -444,7 +444,7 @@ class Editor(W.Window):
try:
code = compile(pytext, filename, "exec")
except (SyntaxError, EOFError):
raise buildtools.BuildError, "Syntax error in script %s" % `filename`
raise buildtools.BuildError, "Syntax error in script %r" % (filename,)
import tempfile
tmpdir = tempfile.mkdtemp()
@ -1262,8 +1262,8 @@ class _EditorDefaultSettings:
self.w.picksizebutton = W.Button((8, 50, 80, 16), "Front window", self.picksize)
self.w.xsizelabel = W.TextBox((98, 32, 40, 14), "Width:")
self.w.ysizelabel = W.TextBox((148, 32, 40, 14), "Height:")
self.w.xsize = W.EditText((98, 48, 40, 20), `self.windowsize[0]`)
self.w.ysize = W.EditText((148, 48, 40, 20), `self.windowsize[1]`)
self.w.xsize = W.EditText((98, 48, 40, 20), repr(self.windowsize[0]))
self.w.ysize = W.EditText((148, 48, 40, 20), repr(self.windowsize[1]))
self.w.cancelbutton = W.Button((-180, -26, 80, 16), "Cancel", self.cancel)
self.w.okbutton = W.Button((-90, -26, 80, 16), "Done", self.ok)
@ -1276,8 +1276,8 @@ class _EditorDefaultSettings:
editor = findeditor(self)
if editor is not None:
width, height = editor._parentwindow._bounds[2:]
self.w.xsize.set(`width`)
self.w.ysize.set(`height`)
self.w.xsize.set(repr(width))
self.w.ysize.set(repr(height))
else:
raise W.AlertError, "No edit window found"

View file

@ -152,4 +152,4 @@ def test(path):
f.close()
tags = fontify(text)
for tag, start, end, sublist in tags:
print tag, `text[start:end]`
print tag, repr(text[start:end])

View file

@ -394,7 +394,7 @@ class PythonIDE(Wapplication.Application):
if arg[0] == -50:
W.Message("Developer documentation not installed")
else:
W.Message("AppleHelp Error: %s" % `arg`)
W.Message("AppleHelp Error: %r" % (arg,))
def domenu_lookuppython(self, *args):
from Carbon import AH
@ -404,7 +404,7 @@ class PythonIDE(Wapplication.Application):
try:
AH.AHSearch("Python Documentation", searchstring)
except AH.Error, arg:
W.Message("AppleHelp Error: %s" % `arg`)
W.Message("AppleHelp Error: %r" % (arg,))
def domenu_lookupcarbon(self, *args):
from Carbon import AH
@ -414,7 +414,7 @@ class PythonIDE(Wapplication.Application):
try:
AH.AHSearch("Carbon", searchstring)
except AH.Error, arg:
W.Message("AppleHelp Error: %s" % `arg`)
W.Message("AppleHelp Error: %r" % (arg,))
def _getsearchstring(self):
# First we get the frontmost window

View file

@ -118,7 +118,7 @@ class Application(FrameWork.Application):
func()
except:
import sys
sys.stderr.write("exception in idle function %s; killed:\n" % `func`)
sys.stderr.write("exception in idle function %r; killed:\n" % (func,))
traceback.print_exc()
self._idlefuncs.remove(func)
break
@ -175,7 +175,7 @@ class Application(FrameWork.Application):
self.do_rawmenu(id, item, None, event)
return # here! we had a menukey!
#else:
# print "XXX Command-" +`ch`
# print "XXX Command-%r" % ch
# See whether the front window wants it
if wid and self._windows.has_key(wid):
window = self._windows[wid]

View file

@ -229,7 +229,7 @@ class Widget:
def _removewidget(self, key):
if not self._widgetsdict.has_key(key):
raise KeyError, "no widget with key " + `key`
raise KeyError, "no widget with key %r" % (key,)
widget = self._widgetsdict[key]
for k in widget._widgetsdict.keys():
widget._removewidget(k)
@ -502,8 +502,8 @@ class HorizontalPanes(Widget):
self._panebounds = []
for i in range(len(self._panesizes)):
panestart, paneend = self._panesizes[i]
boundsstring = self.boundstemplate % (`panestart`, panestart and halfgutter,
`paneend`, (paneend <> 1.0) and -halfgutter)
boundsstring = self.boundstemplate % (repr(panestart), panestart and halfgutter,
repr(paneend), (paneend <> 1.0) and -halfgutter)
self._panebounds.append(eval(boundsstring))
def installbounds(self):
@ -684,9 +684,9 @@ def CallbackCall(callback, mustfit, *args):
return callback()
else:
if mustfit:
raise TypeError, "callback accepts wrong number of arguments: " + `len(args)`
raise TypeError, "callback accepts wrong number of arguments: %r" % len(args)
else:
raise TypeError, "callback accepts wrong number of arguments: 0 or " + `len(args)`
raise TypeError, "callback accepts wrong number of arguments: 0 or %r" % len(args)
def HasBaseClass(obj, class_):

View file

@ -129,14 +129,14 @@ class Connection(asyncore.dispatcher):
data = asyncore.dispatcher.recv(self, BUFSIZE)
if data:
if VERBOSE > 2:
print "incoming ->", "%x" % id(self), `data`
print "incoming -> %x %r" % (id(self), data)
self.handle_incoming_data(data)
def handle_write(self):
if self._out_buffer:
sent = self.socket.send(self._out_buffer[:BUFSIZE])
if VERBOSE > 2:
print "outgoing ->", "%x" % id(self), `self._out_buffer[:sent]`
print "outgoing -> %x %r" % (id(self), self._out_buffer[:sent])
self._out_buffer = self._out_buffer[sent:]
def close(self):
@ -144,7 +144,7 @@ class Connection(asyncore.dispatcher):
self.readfunc(self._in_buffer)
self._in_buffer = ""
#elif VERBOSE > 1 and self._in_buffer:
# print "--- there is unread data:", `self._in_buffer`
# print "--- there is unread data: %r", (self._in_buffer,)
asyncore.dispatcher.close(self)
def handle_close(self):
@ -290,7 +290,7 @@ class PyConnection(Connection):
self.currentmessage = PyMessage()
def handle_object(self, object):
print 'unhandled object:', `object`
print 'unhandled object:', repr(object)
def send(self, object):
import cPickle, zlib, struct
@ -356,7 +356,7 @@ class HTTPProxy(Proxy):
def connectproxy(self, data):
if VERBOSE:
print "--- proxy request", `data`
print "--- proxy request", repr(data)
addr, data = de_proxify(data)
other = Proxy(addr)
self.other = other

View file

@ -147,9 +147,7 @@ class TraceBack:
tbline = ""
if os.path.exists(filename):
filename = os.path.split(filename)[1]
tbline = 'File "' + filename + '", line ' + `lineno` + ', in ' + func
else:
tbline = 'File "' + filename + '", line ' + `lineno` + ', in ' + func
tbline = 'File "%s", line %r, in %r' % (filename, lineno, func)
if line:
tbline = tbline + '\r ' + line
self.textlist.append(tbline[:255])

View file

@ -113,7 +113,7 @@ def dialog(script=None):
try:
debug = string.atoi(string.strip(debug))
except ValueError:
EasyDialogs.Message("Illegal debug value %s, set to zero."%`debug`)
EasyDialogs.Message("Illegal debug value %r, set to zero."%(debug,))
debug = 0
if gentype == ITEM_GENSOURCE:
return 'source', script, dirname, debug

View file

@ -4,5 +4,5 @@ def generate(output, module_dict):
for name in module_dict.keys():
print 'Include %-20s\t'%name,
module = module_dict[name]
print module.gettype(), '\t', `module`
print module.gettype(), '\t', repr(module)
return 0

View file

@ -4,5 +4,5 @@ def generate(program, module_dict):
for name in module_dict.keys():
print 'Include %-20s\t'%name,
module = module_dict[name]
print module.gettype(), '\t', `module`
print module.gettype(), '\t', repr(module)
return 0