17 from pprint
import PrettyPrinter
18 from unicodedata
import normalize
20 from .platform
import PY2, PY3
21 from .robottypes
import is_bytes, is_unicode, unicode
36 if isinstance(item, unicode):
38 if isinstance(item, (bytes, bytearray)):
40 return item.decode(
'ASCII')
42 return u''.join(chr(b)
if b < 128
else '\\x%x' % b
43 for b
in bytearray(item))
48 return unic(str(item))
55 if isinstance(item, str):
57 if isinstance(item, (bytes, bytearray)):
59 return item.decode(
'ASCII')
61 return ''.join(chr(b)
if b < 128
else '\\x%x' % b
75 def format(self, object, context, maxlevels, level):
78 return repr(object).lstrip(
'u'),
True,
False
80 return 'b' + repr(object).lstrip(
'b'),
True,
False
81 return PrettyPrinter.format(self, object, context, maxlevels, level)
88 def _format(self, object, *args, **kwargs):
89 if isinstance(object, (str, bytes, bytearray)):
93 super().
_format(object, *args, **kwargs)
97 super().
_format(object, *args, **kwargs)
101 from .error
import get_error_message
102 return u"<Unrepresentable object %s. Error: %s>" \
def format(self, object, context, maxlevels, level)
def _format(self, object, *args, **kwargs)
unicode
Exceptions and return codes used internally.
def get_error_message()
Returns error message of the last occurred exception.
def normalize(string, ignore=(), caseless=True, spaceless=True)
Normalizes given string according to given spec.
def _unrepresentable_object(item)
def prepr(item, width=80)