##// END OF EJS Templates
parser: replace bespoke _brepr with stringutil.pprint...
Augie Fackler -
r39085:0a2ce5b4 default
parent child Browse files
Show More
@@ -20,7 +20,6 b' from __future__ import absolute_import, '
20
20
21 from .i18n import _
21 from .i18n import _
22 from . import (
22 from . import (
23 encoding,
24 error,
23 error,
25 pycompat,
24 pycompat,
26 util,
25 util,
@@ -198,16 +197,11 b' def unescapestr(s):'
198 # mangle Python's exception into our format
197 # mangle Python's exception into our format
199 raise error.ParseError(pycompat.bytestr(e).lower())
198 raise error.ParseError(pycompat.bytestr(e).lower())
200
199
201 def _brepr(obj):
202 if isinstance(obj, bytes):
203 return b"'%s'" % stringutil.escapestr(obj)
204 return encoding.strtolocal(repr(obj))
205
206 def _prettyformat(tree, leafnodes, level, lines):
200 def _prettyformat(tree, leafnodes, level, lines):
207 if not isinstance(tree, tuple):
201 if not isinstance(tree, tuple):
208 lines.append((level, _brepr(tree)))
202 lines.append((level, stringutil.pprint(tree)))
209 elif tree[0] in leafnodes:
203 elif tree[0] in leafnodes:
210 rs = map(_brepr, tree[1:])
204 rs = map(stringutil.pprint, tree[1:])
211 lines.append((level, '(%s %s)' % (tree[0], ' '.join(rs))))
205 lines.append((level, '(%s %s)' % (tree[0], ' '.join(rs))))
212 else:
206 else:
213 lines.append((level, '(%s' % tree[0]))
207 lines.append((level, '(%s' % tree[0]))
General Comments 0
You need to be logged in to leave comments. Login now