Exemplo n.º 1
0
def my_safe_repr(object, context, maxlevels, level):
    typ = pprint._type(object)
    if typ is unicode:
        r = 'u"%s"' % (object.encode("utf8").replace('"', r'\"'))
        return (r, True, False)
    else:
        return pprint._safe_repr(object, context, maxlevels, level)
Exemplo n.º 2
0
def my_safe_repr(object, context, maxlevels, level):
    typ = pprint._type(object)
    if typ is unicode:
        r = 'u"%s"' % (object.encode("utf8").replace('"', r'\"'))
        return (r, True, False)
    else:
        return pprint._safe_repr(object, context, maxlevels, level)
Exemplo n.º 3
0
    def ascii_format(object_, context, maxlevels, level):
        typ = pprint._type(object_)
        if typ is unicode:
            object_ = str(object_).replace('"', '\\"')  # replace " to '
            rep = "\"%s\"" % object_  # repr(object_)
            return rep, (rep and not rep.startswith('<')), False

        return pprint._safe_repr(object_, context, maxlevels, level)
Exemplo n.º 4
0
    def ascii_format(object_, context, maxlevels, level):
        typ = pprint._type(object_)
        if typ is unicode:
            object_ = str(object_).replace('"', '\\"')  # replace " to '
            rep = "\"%s\"" % object_  # repr(object_)
            return rep, (rep and not rep.startswith('<')), False

        return pprint._safe_repr(object_, context, maxlevels, level)
Exemplo n.º 5
0
def pprintFormatter(thing, context, maxlevels, level):
    typ = pprint._type(thing)
    if typ is unicode:
        thing = str(thing)
    return pprint._safe_repr(thing, context, maxlevels, level)
Exemplo n.º 6
0
def format_print(object, context, maxlevels, level):
    typ = pprint._type(object)
    if typ is unicode:
        object = str(object)
    return pprint._safe_repr(object, context, maxlevels, level)
Exemplo n.º 7
0
def my_safe_repr(object, context, maxlevels, level):
	typ = pprint._type(object)
	if typ is unicode:
		object = str(object)
	return pprint._safe_repr(object, context, maxlevels, level)
Exemplo n.º 8
0
def no_unicode(object, context, maxlevels, level):
    """ change unicode u'foo' to string 'foo' when pretty printing"""
    if pprint._type(object) is unicode:
        object = str(object)
    return pprint._safe_repr(object, context, maxlevels, level)
Exemplo n.º 9
0
def concat(object, context, maxlevels, level):
    """ Concatenate any string which pprint displays.  This is recursive, so it also should apply to dictionary keys and values, for example."""
    if pprint._type(object) is (unicode or str):
        if len(object) > pprint_concatenation_length:
            object = object[:pprint_concatenation_length] + '...'
    return pprint._safe_repr(object, context, maxlevels, level)
Exemplo n.º 10
0
def suppress_unicode_repr(object, context, maxlevels, level):
    typ = pprint._type(object)
    if typ is unicode:
        object = str(object)
    return pprint._safe_repr(object, context, maxlevels, level)
Exemplo n.º 11
0
def my_safe_repr(object, context, maxlevels, level):
    typ = pprint._type(object)
    if typ is unicode:
        object = str(object.encode('utf-8'))
    return pprint._safe_repr(object, context, maxlevels, level)
 def de_unicode(object, context, maxlevels, level):
     if pprint._type(object) is unicode: object = str(object)
     return pprint._safe_repr(object, context, maxlevels, level)
Exemplo n.º 13
0
def no_unicode(object, context, maxlevels, level):
    """ change unicode u'foo' to string 'foo' when pretty printing"""
    if pprint._type(object) is unicode:
        object = str(object)
    return pprint._safe_repr(object, context, maxlevels, level)