Skip to content

Commit 8a30b60

Browse files
committed
Python 3 preparation: use repr() instead of ``.
Tool-generated patch.
1 parent a3ce8f9 commit 8a30b60

File tree

11 files changed

+49
-49
lines changed

11 files changed

+49
-49
lines changed

roundup/cgi/PageTemplates/Expressions.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,10 @@ def __call__(self, econtext):
193193
return self._eval(econtext)
194194

195195
def __str__(self):
196-
return '%s expression %s' % (self._name, `self._s`)
196+
return '%s expression %s' % (self._name, repr(self._s))
197197

198198
def __repr__(self):
199-
return '%s:%s' % (self._name, `self._s`)
199+
return '%s:%s' % (self._name, repr(self._s))
200200

201201

202202
_interp = re.compile(r'\$(%(n)s)|\${(%(n)s(?:/[^}]*)*)}' % {'n': NAME_RE})
@@ -237,10 +237,10 @@ def __call__(self, econtext):
237237
return self._expr % tuple(vvals)
238238

239239
def __str__(self):
240-
return 'string expression %s' % `self._s`
240+
return 'string expression %s' % repr(self._s)
241241

242242
def __repr__(self):
243-
return 'string:%s' % `self._s`
243+
return 'string:%s' % repr(self._s)
244244

245245
class NotExpr:
246246
def __init__(self, name, expr, compiler):
@@ -254,7 +254,7 @@ def __call__(self, econtext):
254254
return (not econtext.evaluateBoolean(self._c)) and 1 or 0
255255

256256
def __repr__(self):
257-
return 'not:%s' % `self._s`
257+
return 'not:%s' % repr(self._s)
258258

259259
class DeferWrapper:
260260
def __init__(self, expr, econtext):
@@ -276,7 +276,7 @@ def __call__(self, econtext):
276276
return DeferWrapper(self._c, econtext)
277277

278278
def __repr__(self):
279-
return 'defer:%s' % `self._s`
279+
return 'defer:%s' % repr(self._s)
280280

281281
class TraversalError:
282282
def __init__(self, path, name):

roundup/cgi/PageTemplates/TALES.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,4 +295,4 @@ def __init__(self, name, expr, engine):
295295
def __call__(self, econtext):
296296
return self._name, self._expr
297297
def __repr__(self):
298-
return '<SimpleExpr %s %s>' % (self._name, `self._expr`)
298+
return '<SimpleExpr %s %s>' % (self._name, repr(self._expr))

roundup/cgi/TAL/DummyEngine.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def evaluate(self, expression):
119119
try:
120120
return eval(expr, self.globals, self.locals)
121121
except:
122-
raise TALESError("evaluation error in %s" % `expr`)
122+
raise TALESError("evaluation error in %s" % repr(expr))
123123
if type == "position":
124124
# Insert the current source file name, line number,
125125
# and column offset.
@@ -128,7 +128,7 @@ def evaluate(self, expression):
128128
else:
129129
lineno, offset = None, None
130130
return '%s (%s,%s)' % (self.source_file, lineno, offset)
131-
raise TALESError("unrecognized expression: " + `expression`)
131+
raise TALESError("unrecognized expression: " + repr(expression))
132132

133133
def evaluatePathOrVar(self, expr):
134134
expr = expr.strip()
@@ -137,7 +137,7 @@ def evaluatePathOrVar(self, expr):
137137
elif self.globals.has_key(expr):
138138
return self.globals[expr]
139139
else:
140-
raise TALESError("unknown variable: %s" % `expr`)
140+
raise TALESError("unknown variable: %s" % repr(expr))
141141

142142
def evaluateValue(self, expr):
143143
return self.evaluate(expr)

roundup/cgi/TAL/HTMLParser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def parse_starttag(self, i):
285285
else:
286286
offset = offset + len(self.__starttag_text)
287287
self.error("junk characters in start tag: %s"
288-
% `rawdata[k:endpos][:20]`)
288+
% repr(rawdata[k:endpos][:20]))
289289
if end[-2:] == '/>':
290290
# XHTML-style empty tag: <span attr="value" />
291291
self.handle_startendtag(tag, attrs)
@@ -337,7 +337,7 @@ def parse_endtag(self, i):
337337
j = match.end()
338338
match = endtagfind.match(rawdata, i) # </ + tag + >
339339
if not match:
340-
self.error("bad end tag: %s" % `rawdata[i:j]`)
340+
self.error("bad end tag: %s" % repr(rawdata[i:j]))
341341
tag = match.group(1).lower()
342342
if ( self.cdata_endtag is not None
343343
and tag != self.cdata_endtag):
@@ -388,7 +388,7 @@ def handle_pi(self, data):
388388
pass
389389

390390
def unknown_decl(self, data):
391-
self.error("unknown declaration: " + `data`)
391+
self.error("unknown declaration: " + repr(data))
392392

393393
# Internal -- helper to remove special character quoting
394394
def unescape(self, s):

roundup/cgi/TAL/HTMLTALParser.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def handle_starttag(self, tag, attrs):
144144
= self.process_ns(tag, attrs)
145145
if tag in EMPTY_HTML_TAGS and taldict.get("content"):
146146
raise TALError(
147-
"empty HTML tags cannot use tal:content: %s" % `tag`,
147+
"empty HTML tags cannot use tal:content: %s" % repr(tag),
148148
self.getpos())
149149
self.tagstack.append(tag)
150150
self.gen.emitStartElement(tag, attrlist, taldict, metaldict, i18ndict,
@@ -160,7 +160,7 @@ def handle_startendtag(self, tag, attrs):
160160
if taldict.get("content"):
161161
if tag in EMPTY_HTML_TAGS:
162162
raise TALError(
163-
"empty HTML tags cannot use tal:content: %s" % `tag`,
163+
"empty HTML tags cannot use tal:content: %s" % repr(tag),
164164
self.getpos())
165165
self.gen.emitStartElement(tag, attrlist, taldict, metaldict,
166166
i18ndict, self.getpos())
@@ -297,17 +297,17 @@ def process_ns(self, name, attrs):
297297
if ns == 'tal':
298298
if taldict.has_key(keybase):
299299
raise TALError("duplicate TAL attribute " +
300-
`keybase`, self.getpos())
300+
repr(keybase), self.getpos())
301301
taldict[keybase] = value
302302
elif ns == 'metal':
303303
if metaldict.has_key(keybase):
304304
raise METALError("duplicate METAL attribute " +
305-
`keybase`, self.getpos())
305+
repr(keybase), self.getpos())
306306
metaldict[keybase] = value
307307
elif ns == 'i18n':
308308
if i18ndict.has_key(keybase):
309309
raise I18NError("duplicate i18n attribute " +
310-
`keybase`, self.getpos())
310+
repr(keybase), self.getpos())
311311
i18ndict[keybase] = value
312312
attrlist.append(item)
313313
if namens in ('metal', 'tal'):

roundup/cgi/TAL/TALDefs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,19 @@ def parseAttributeReplacements(arg, xml):
122122
for part in splitParts(arg):
123123
m = _attr_re.match(part)
124124
if not m:
125-
raise TALError("Bad syntax in attributes: " + `part`)
125+
raise TALError("Bad syntax in attributes: " + repr(part))
126126
name, expr = m.group(1, 2)
127127
if not xml:
128128
name = name.lower()
129129
if dict.has_key(name):
130-
raise TALError("Duplicate attribute name in attributes: " + `part`)
130+
raise TALError("Duplicate attribute name in attributes: " + repr(part))
131131
dict[name] = expr
132132
return dict
133133

134134
def parseSubstitution(arg, position=(None, None)):
135135
m = _subst_re.match(arg)
136136
if not m:
137-
raise TALError("Bad syntax in substitution text: " + `arg`, position)
137+
raise TALError("Bad syntax in substitution text: " + repr(arg), position)
138138
key, expr = m.group(1, 2)
139139
if not key:
140140
key = "text"

roundup/cgi/TAL/TALGenerator.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def compileExpression(self, expr):
207207
try:
208208
return self.expressionCompiler.compile(expr)
209209
except self.CompilerError as err:
210-
raise TALError('%s in expression %s' % (err.args[0], `expr`),
210+
raise TALError('%s in expression %s' % (err.args[0], repr(expr)),
211211
self.position)
212212

213213
def pushProgram(self):
@@ -268,7 +268,7 @@ def emitDefines(self, defines):
268268
m = re.match(
269269
r"(?s)\s*(?:(global|local)\s+)?(%s)\s+(.*)\Z" % NAME_RE, part)
270270
if not m:
271-
raise TALError("invalid define syntax: " + `part`,
271+
raise TALError("invalid define syntax: " + repr(part),
272272
self.position)
273273
scope, name, expr = m.group(1, 2, 3)
274274
scope = scope or "local"
@@ -302,7 +302,7 @@ def emitCondition(self, expr):
302302
def emitRepeat(self, arg):
303303
m = re.match("(?s)\s*(%s)\s+(.*)\Z" % NAME_RE, arg)
304304
if not m:
305-
raise TALError("invalid repeat syntax: " + `arg`,
305+
raise TALError("invalid repeat syntax: " + repr(arg),
306306
self.position)
307307
name, expr = m.group(1, 2)
308308
cexpr = self.compileExpression(expr)
@@ -370,10 +370,10 @@ def emitDefineMacro(self, macroName):
370370
program = self.popProgram()
371371
macroName = macroName.strip()
372372
if self.macros.has_key(macroName):
373-
raise METALError("duplicate macro definition: %s" % `macroName`,
373+
raise METALError("duplicate macro definition: %s" % repr(macroName),
374374
self.position)
375375
if not re.match('%s$' % NAME_RE, macroName):
376-
raise METALError("invalid macro name: %s" % `macroName`,
376+
raise METALError("invalid macro name: %s" % repr(macroName),
377377
self.position)
378378
self.macros[macroName] = program
379379
self.inMacroDef = self.inMacroDef - 1
@@ -389,18 +389,18 @@ def emitDefineSlot(self, slotName):
389389
program = self.popProgram()
390390
slotName = slotName.strip()
391391
if not re.match('%s$' % NAME_RE, slotName):
392-
raise METALError("invalid slot name: %s" % `slotName`,
392+
raise METALError("invalid slot name: %s" % repr(slotName),
393393
self.position)
394394
self.emit("defineSlot", slotName, program)
395395

396396
def emitFillSlot(self, slotName):
397397
program = self.popProgram()
398398
slotName = slotName.strip()
399399
if self.slots.has_key(slotName):
400-
raise METALError("duplicate fill-slot name: %s" % `slotName`,
400+
raise METALError("duplicate fill-slot name: %s" % repr(slotName),
401401
self.position)
402402
if not re.match('%s$' % NAME_RE, slotName):
403-
raise METALError("invalid slot name: %s" % `slotName`,
403+
raise METALError("invalid slot name: %s" % repr(slotName),
404404
self.position)
405405
self.slots[slotName] = program
406406
self.inMacroUse = 1
@@ -487,23 +487,23 @@ def emitStartElement(self, name, attrlist, taldict, metaldict, i18ndict,
487487
self.position = position
488488
for key, value in taldict.items():
489489
if key not in TALDefs.KNOWN_TAL_ATTRIBUTES:
490-
raise TALError("bad TAL attribute: " + `key`, position)
490+
raise TALError("bad TAL attribute: " + repr(key), position)
491491
if not (value or key == 'omit-tag'):
492492
raise TALError("missing value for TAL attribute: " +
493-
`key`, position)
493+
repr(key), position)
494494
for key, value in metaldict.items():
495495
if key not in TALDefs.KNOWN_METAL_ATTRIBUTES:
496-
raise METALError("bad METAL attribute: " + `key`,
496+
raise METALError("bad METAL attribute: " + repr(key),
497497
position)
498498
if not value:
499499
raise TALError("missing value for METAL attribute: " +
500-
`key`, position)
500+
repr(key), position)
501501
for key, value in i18ndict.items():
502502
if key not in TALDefs.KNOWN_I18N_ATTRIBUTES:
503-
raise I18NError("bad i18n attribute: " + `key`, position)
503+
raise I18NError("bad i18n attribute: " + repr(key), position)
504504
if not value and key in ("attributes", "data", "id"):
505505
raise I18NError("missing value for i18n attribute: " +
506-
`key`, position)
506+
repr(key), position)
507507
todo = {}
508508
defineMacro = metaldict.get("define-macro")
509509
useMacro = metaldict.get("use-macro")

roundup/cgi/TAL/TALInterpreter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def interpolate(text, mapping):
7676
# subst contains high-bit chars...
7777
# As we have no way of knowing the correct encoding,
7878
# substitue something instead of raising an exception.
79-
subst = `subst`[1:-1]
79+
subst = repr(subst)[1:-1]
8080
text = text.replace(string, subst)
8181
return text
8282

@@ -179,7 +179,7 @@ def restoreOutputState(self, state):
179179
def pushMacro(self, macroName, slots, entering=1):
180180
if len(self.macroStack) >= self.stackLimit:
181181
raise METALError("macro nesting limit (%d) exceeded "
182-
"by %s" % (self.stackLimit, `macroName`))
182+
"by %s" % (self.stackLimit, repr(macroName)))
183183
self.macroStack.append([macroName, slots, entering, self.i18nContext])
184184

185185
def popMacro(self):
@@ -655,12 +655,12 @@ def do_useMacro(self, (macroName, macroExpr, compiledSlots, block)):
655655
else:
656656
if not isCurrentVersion(macro):
657657
raise METALError("macro %s has incompatible version %s" %
658-
(`macroName`, `getProgramVersion(macro)`),
658+
(repr(macroName), repr(getProgramVersion(macro))),
659659
self.position)
660660
mode = getProgramMode(macro)
661661
if mode != (self.html and "html" or "xml"):
662662
raise METALError("macro %s has incompatible mode %s" %
663-
(`macroName`, `mode`), self.position)
663+
(repr(macroName), repr(mode)), self.position)
664664
self.pushMacro(macroName, compiledSlots)
665665
prev_source = self.sourceFile
666666
self.interpret(macro)

roundup/cgi/TAL/TALParser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def process_ns(self, name, attrlist):
8080
taldict[keybase] = value
8181
item = item + ("tal",)
8282
elif ns == 'i18n':
83-
assert 0, "dealing with i18n: " + `(keybase, value)`
83+
assert 0, "dealing with i18n: " + repr((keybase, value))
8484
i18ndict[keybase] = value
8585
item = item + ('i18n',)
8686
fixedattrlist.append(item)

roundup/cgi/TAL/markupbase.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def parse_declaration(self, i):
9292
self.error("unexpected '[' char in declaration")
9393
else:
9494
self.error(
95-
"unexpected %s char in declaration" % `rawdata[j]`)
95+
"unexpected %s char in declaration" % repr(rawdata[j]))
9696
if j < 0:
9797
return j
9898
return -1 # incomplete
@@ -113,7 +113,7 @@ def _parse_doctype_subset(self, i, declstartpos):
113113
if s != "<!":
114114
self.updatepos(declstartpos, j + 1)
115115
self.error("unexpected char in internal subset (in %s)"
116-
% `s`)
116+
% repr(s))
117117
if (j + 2) == n:
118118
# end of buffer; incomplete
119119
return -1
@@ -131,7 +131,7 @@ def _parse_doctype_subset(self, i, declstartpos):
131131
if name not in ("attlist", "element", "entity", "notation"):
132132
self.updatepos(declstartpos, j + 2)
133133
self.error(
134-
"unknown declaration %s in internal subset" % `name`)
134+
"unknown declaration %s in internal subset" % repr(name))
135135
# handle the individual names
136136
meth = getattr(self, "_parse_doctype_" + name)
137137
j = meth(j, declstartpos)
@@ -162,7 +162,7 @@ def _parse_doctype_subset(self, i, declstartpos):
162162
j = j + 1
163163
else:
164164
self.updatepos(declstartpos, j)
165-
self.error("unexpected char %s in internal subset" % `c`)
165+
self.error("unexpected char %s in internal subset" % repr(c))
166166
# end of buffer reached
167167
return -1
168168

0 commit comments

Comments
 (0)