Otherwise they get serialized as e.g.
<generator object X at 0x7f543d3d68c0>
( )
pulkit |
hg-reviewers |
Otherwise they get serialized as e.g.
<generator object X at 0x7f543d3d68c0>
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/utils/stringutil.py (3 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Gregory Szorc | Aug 22 2018, 2:58 PM |
# stringutil.py - utility for generic string formatting, parsing, etc. | # stringutil.py - utility for generic string formatting, parsing, etc. | ||||
# | # | ||||
# Copyright 2005 K. Thananchayan <thananck@yahoo.com> | # Copyright 2005 K. Thananchayan <thananck@yahoo.com> | ||||
# Copyright 2005-2007 Matt Mackall <mpm@selenic.com> | # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> | ||||
# Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> | # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> | ||||
# | # | ||||
# This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
# GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
from __future__ import absolute_import | from __future__ import absolute_import | ||||
import ast | import ast | ||||
import codecs | import codecs | ||||
import re as remod | import re as remod | ||||
import textwrap | import textwrap | ||||
import types | |||||
from ..i18n import _ | from ..i18n import _ | ||||
from ..thirdparty import attr | from ..thirdparty import attr | ||||
from .. import ( | from .. import ( | ||||
encoding, | encoding, | ||||
error, | error, | ||||
pycompat, | pycompat, | ||||
'%s: %s' % (pprint(k, bprefix=bprefix), | '%s: %s' % (pprint(k, bprefix=bprefix), | ||||
pprint(v, bprefix=bprefix)) | pprint(v, bprefix=bprefix)) | ||||
for k, v in sorted(o.items()))) | for k, v in sorted(o.items()))) | ||||
elif isinstance(o, set): | elif isinstance(o, set): | ||||
return 'set([%s])' % (b', '.join( | return 'set([%s])' % (b', '.join( | ||||
pprint(k, bprefix=bprefix) for k in sorted(o))) | pprint(k, bprefix=bprefix) for k in sorted(o))) | ||||
elif isinstance(o, tuple): | elif isinstance(o, tuple): | ||||
return '(%s)' % (b', '.join(pprint(a, bprefix=bprefix) for a in o)) | return '(%s)' % (b', '.join(pprint(a, bprefix=bprefix) for a in o)) | ||||
elif isinstance(o, types.GeneratorType): | |||||
return 'gen[%s]' % (b', '.join(pprint(a, bprefix=bprefix) for a in o)) | |||||
else: | else: | ||||
return pycompat.byterepr(o) | return pycompat.byterepr(o) | ||||
def prettyrepr(o): | def prettyrepr(o): | ||||
"""Pretty print a representation of a possibly-nested object""" | """Pretty print a representation of a possibly-nested object""" | ||||
lines = [] | lines = [] | ||||
rs = pycompat.byterepr(o) | rs = pycompat.byterepr(o) | ||||
p0 = p1 = 0 | p0 = p1 = 0 |