コード例 #1
0
def _do_quote(elem):
    """ Quote the elem safely,
    e.g. encoding it first if necessary and decoding again after quoting.

    Note that strings in Python 2 are 'str' or 'unicode' types,
    'quote' function works only with 'str' and 'unicode' in ASCII types.
    In Python 3 all strings are unicode and have 'str' type,
    'quote' function works well with 'str' and 'bytes' types.

    :param elem: name or value of variable
    :type elem: str, unicode, bytes
    :return: elem in UTF-8
    :rtype: unicode, str
    """
    if not IS_PY3K:
        if elem.__class__.__name__ == 'unicode':
            # unicode to str
            result = elem.encode('utf-8')
            result = quote(result, '/>_= ')
            # str to unicode in UTF-8
            result = result.decode('utf-8')
        else:
            result = quote(elem, '/>_= ')
    else:
        result = quote(elem, '/>_= ')

    return result
コード例 #2
0
def header_data_to_xml(rows, cols, dtypes, col_bounds, col_to_format, df, dim):
    xml = "<headerdata rows=\"%s\" cols=\"%s\">\n" % (rows, cols)
    for col in range(cols):
        col_label = quote(get_label(df.axes[1][col]) if dim > 1 else str(col))
        bounds = col_bounds[col]
        col_format = "%" + col_to_format(dtypes[col])
        xml += '<colheader index=\"%s\" label=\"%s\" type=\"%s\" format=\"%s\" max=\"%s\" min=\"%s\" />\n' % \
               (str(col), col_label, dtypes[col], col_to_format(dtypes[col]), col_format % bounds[1], col_format % bounds[0])
    for row in range(rows):
        xml += "<rowheader index=\"%s\" label = \"%s\"/>\n" % (
            str(row), quote(get_label(df.axes[0][row])))
    xml += "</headerdata>\n"
    return xml
コード例 #3
0
def var_to_xml(val,
               name,
               trim_if_too_big=True,
               additional_in_xml='',
               evaluate_full_value=True):
    """ single variable or dictionary to xml representation """

    type_name, type_qualifier, is_exception_on_eval, resolver, value = get_variable_details(
        val, evaluate_full_value)

    scope = get_var_scope(name, val, '', True)
    try:
        name = quote(name, '/>_= ')  # TODO: Fix PY-5834 without using quote
    except:
        pass

    xml = '<var name="%s" type="%s" ' % (make_valid_xml_value(name),
                                         make_valid_xml_value(type_name))

    if type_qualifier:
        xml_qualifier = 'qualifier="%s"' % make_valid_xml_value(type_qualifier)
    else:
        xml_qualifier = ''

    if value:
        # cannot be too big... communication may not handle it.
        if len(value
               ) > MAXIMUM_VARIABLE_REPRESENTATION_SIZE and trim_if_too_big:
            value = value[0:MAXIMUM_VARIABLE_REPRESENTATION_SIZE]
            value += '...'

        xml_value = ' value="%s"' % (make_valid_xml_value(quote(
            value, '/>_= ')))
    else:
        xml_value = ''

    if is_exception_on_eval:
        xml_container = ' isErrorOnEval="True"'
    else:
        if resolver is not None:
            xml_container = ' isContainer="True"'
        else:
            xml_container = ''

    if scope:
        return ''.join((xml, xml_qualifier, xml_value, xml_container,
                        additional_in_xml, ' scope="', scope, '"', ' />\n'))
    else:
        return ''.join((xml, xml_qualifier, xml_value, xml_container,
                        additional_in_xml, ' />\n'))
コード例 #4
0
ファイル: pydevd_xml.py プロジェクト: ku5ic/dotfiles
def var_to_xml(val, name, trim_if_too_big=True, additional_in_xml='', evaluate_full_value=True):
    """ single variable or dictionary to xml representation """

    type_name, type_qualifier, is_exception_on_eval, resolver, value = get_variable_details(
        val, evaluate_full_value)

    try:
        name = quote(name, '/>_= ')  # TODO: Fix PY-5834 without using quote
    except:
        pass

    xml = '<var name="%s" type="%s" ' % (make_valid_xml_value(name), make_valid_xml_value(type_name))

    if type_qualifier:
        xml_qualifier = 'qualifier="%s"' % make_valid_xml_value(type_qualifier)
    else:
        xml_qualifier = ''

    if value:
        # cannot be too big... communication may not handle it.
        if len(value) > MAXIMUM_VARIABLE_REPRESENTATION_SIZE and trim_if_too_big:
            value = value[0:MAXIMUM_VARIABLE_REPRESENTATION_SIZE]
            value += '...'

        xml_value = ' value="%s"' % (make_valid_xml_value(quote(value, '/>_= ')))
    else:
        xml_value = ''

    if is_exception_on_eval:
        xml_container = ' isErrorOnEval="True"'
    else:
        if resolver is not None:
            xml_container = ' isContainer="True"'
        else:
            xml_container = ''

    return ''.join((xml, xml_qualifier, xml_value, xml_container, additional_in_xml, ' />\n'))
コード例 #5
0
def var_to_xml(val,
               name,
               doTrim=True,
               additional_in_xml='',
               evaluate_full_value=True):
    """ single variable or dictionary to xml representation """

    try:
        # This should be faster than isinstance (but we have to protect against not having a '__class__' attribute).
        is_exception_on_eval = val.__class__ == ExceptionOnEvaluate
    except:
        is_exception_on_eval = False

    if is_exception_on_eval:
        v = val.result
    else:
        v = val

    _type, typeName, resolver = get_type(v)
    type_qualifier = getattr(_type, "__module__", "")
    if not evaluate_full_value:
        value = DEFAULT_VALUES_DICT[LOAD_VALUES_POLICY]
    else:
        try:
            str_from_provider = _str_from_providers(v, _type, typeName)
            if str_from_provider is not None:
                value = str_from_provider
            elif hasattr(v, '__class__'):
                if v.__class__ == frame_type:
                    value = pydevd_resolver.frameResolver.get_frame_name(v)

                elif v.__class__ in (list, tuple, set, frozenset, dict):
                    if len(v) > pydevd_resolver.MAX_ITEMS_TO_HANDLE:
                        value = '%s: %s' % (
                            str(v.__class__),
                            take_first_n_coll_elements(
                                v, pydevd_resolver.MAX_ITEMS_TO_HANDLE))
                        value = value.rstrip(')]}') + '...'
                    else:
                        value = '%s: %s' % (str(v.__class__), v)
                else:
                    try:
                        cName = str(v.__class__)
                        if cName.find('.') != -1:
                            cName = cName.split('.')[-1]

                        elif cName.find(
                                "'"
                        ) != -1:  # does not have '.' (could be something like <type 'int'>)
                            cName = cName[cName.index("'") + 1:]

                        if cName.endswith("'>"):
                            cName = cName[:-2]
                    except:
                        cName = str(v.__class__)

                    value = '%s: %s' % (cName, v)
            else:
                value = str(v)
        except:
            try:
                value = repr(v)
            except:
                value = 'Unable to get repr for %s' % v.__class__

    try:
        name = quote(name, '/>_= ')  # TODO: Fix PY-5834 without using quote
    except:
        pass

    xml = '<var name="%s" type="%s" ' % (make_valid_xml_value(name),
                                         make_valid_xml_value(typeName))

    if type_qualifier:
        xml_qualifier = 'qualifier="%s"' % make_valid_xml_value(type_qualifier)
    else:
        xml_qualifier = ''

    if value:
        # cannot be too big... communication may not handle it.
        if len(value) > MAXIMUM_VARIABLE_REPRESENTATION_SIZE and doTrim:
            value = value[0:MAXIMUM_VARIABLE_REPRESENTATION_SIZE]
            value += '...'

        # fix to work with unicode values
        try:
            if not IS_PY3K:
                if value.__class__ == unicode:  # @UndefinedVariable
                    value = value.encode('utf-8')
            else:
                if value.__class__ == bytes:
                    value = value.encode('utf-8')
        except TypeError:  # in java, unicode is a function
            pass

        xml_value = ' value="%s"' % (make_valid_xml_value(quote(
            value, '/>_= ')))
    else:
        xml_value = ''

    if is_numeric_container(typeName):
        xml_shape = ' shape="%s"' % make_valid_xml_value(str(v.shape))
    else:
        xml_shape = ''

    if is_exception_on_eval:
        xml_container = ' isErrorOnEval="True"'
    else:
        if resolver is not None:
            xml_container = ' isContainer="True"'
        else:
            xml_container = ''

    return ''.join((xml, xml_qualifier, xml_value, xml_container, xml_shape,
                    additional_in_xml, ' />\n'))
コード例 #6
0
ファイル: pydevd_xml.py プロジェクト: mtslzr/dotfiles
def var_to_xml(val, name, doTrim=True, additional_in_xml='', evaluate_full_value=True):
    """ single variable or dictionary to xml representation """

    try:
        # This should be faster than isinstance (but we have to protect against not having a '__class__' attribute).
        is_exception_on_eval = val.__class__ == ExceptionOnEvaluate
    except:
        is_exception_on_eval = False

    if is_exception_on_eval:
        v = val.result
    else:
        v = val

    _type, typeName, resolver = get_type(v)
    type_qualifier = getattr(_type, "__module__", "")
    if not evaluate_full_value:
        value = DEFAULT_VALUE
    else:
        try:
            str_from_provider = _str_from_providers(v, _type, typeName)
            if str_from_provider is not None:
                value = str_from_provider
            elif hasattr(v, '__class__'):
                if v.__class__ == frame_type:
                    value = pydevd_resolver.frameResolver.get_frame_name(v)

                elif v.__class__ in (list, tuple):
                    if len(v) > 300:
                        value = '%s: %s' % (str(v.__class__), '<Too big to print. Len: %s>' % (len(v),))
                    else:
                        value = '%s: %s' % (str(v.__class__), v)
                else:
                    try:
                        cName = str(v.__class__)
                        if cName.find('.') != -1:
                            cName = cName.split('.')[-1]

                        elif cName.find("'") != -1:  # does not have '.' (could be something like <type 'int'>)
                            cName = cName[cName.index("'") + 1:]

                        if cName.endswith("'>"):
                            cName = cName[:-2]
                    except:
                        cName = str(v.__class__)

                    value = '%s: %s' % (cName, v)
            else:
                value = str(v)
        except:
            try:
                value = repr(v)
            except:
                value = 'Unable to get repr for %s' % v.__class__

    try:
        name = quote(name, '/>_= ')  # TODO: Fix PY-5834 without using quote
    except:
        pass

    xml = '<var name="%s" type="%s" ' % (make_valid_xml_value(name), make_valid_xml_value(typeName))

    if type_qualifier:
        xml_qualifier = 'qualifier="%s"' % make_valid_xml_value(type_qualifier)
    else:
        xml_qualifier = ''

    if value:
        # cannot be too big... communication may not handle it.
        if len(value) > MAXIMUM_VARIABLE_REPRESENTATION_SIZE and doTrim:
            value = value[0:MAXIMUM_VARIABLE_REPRESENTATION_SIZE]
            value += '...'

        # fix to work with unicode values
        try:
            if not IS_PY3K:
                if value.__class__ == unicode:  # @UndefinedVariable
                    value = value.encode('utf-8')
            else:
                if value.__class__ == bytes:
                    value = value.encode('utf-8')
        except TypeError:  # in java, unicode is a function
            pass

        xml_value = ' value="%s"' % (make_valid_xml_value(quote(value, '/>_= ')))
    else:
        xml_value = ''

    if is_exception_on_eval:
        xml_container = ' isErrorOnEval="True"'
    else:
        if resolver is not None:
            xml_container = ' isContainer="True"'
        else:
            xml_container = ''

    return ''.join((xml, xml_qualifier, xml_value, xml_container, additional_in_xml, ' />\n'))
コード例 #7
0
def slice_to_xml(slice, rows, cols, format, type, bounds):
    return '<array slice=\"%s\" rows=\"%s\" cols=\"%s\" format=\"%s\" type=\"%s\" max=\"%s\" min=\"%s\"/>' % \
           (slice, rows, cols, quote(format), type, bounds[1], bounds[0])
def var_to_xml(val,
               name,
               doTrim=True,
               additionalInXml='',
               return_value=False,
               ipython_hidden=False):
    """ single variable or dictionary to xml representation """

    is_exception_on_eval = isinstance(val, ExceptionOnEvaluate)

    if is_exception_on_eval:
        v = val.result
    else:
        v = val

    _type, typeName, resolver = get_type(v)

    ##########################################Adjustment Made by User##################################################
    if typeName in ['module', 'ExitAutocall', 'unicode'] \
            or name in['__name__', '__doc__', '__package__', '_dh', 'In', '_i1', '_iii', '_i2', '_i', '_ii'
                       'get_ipython', 'In', 'Out', '_oh', '_ih', '_', '__', '___']:
        return ''
    ###################################################################################################################

    type_qualifier = getattr(_type, "__module__", "")
    do_not_call_value_str = resolver is not None and resolver.use_value_repr_instead_of_str

    try:
        if hasattr(v, '__class__'):
            if v.__class__ == frame_type:
                value = pydevd_resolver.frameResolver.get_frame_name(v)

            elif v.__class__ in (list, tuple):
                if len(v) > 300:
                    value = '%s: %s' % (str(
                        v.__class__), '<Too big to print. Len: %s>' %
                                        (len(v), ))
                else:
                    value = '%s: %s' % (str(v.__class__), v)
            else:
                try:
                    cName = str(v.__class__)
                    if cName.find('.') != -1:
                        cName = cName.split('.')[-1]

                    elif cName.find(
                            "'"
                    ) != -1:  #does not have '.' (could be something like <type 'int'>)
                        cName = cName[cName.index("'") + 1:]

                    if cName.endswith("'>"):
                        cName = cName[:-2]
                except:
                    cName = str(v.__class__)

                if do_not_call_value_str:
                    value = '%s: %r' % (cName, v)
                else:
                    value = '%s: %s' % (cName, v)
        else:
            value = str(v)
    except:
        try:
            value = repr(v)
        except:
            value = 'Unable to get repr for %s' % v.__class__

    try:
        name = quote(name, '/>_= ')  #TODO: Fix PY-5834 without using quote
    except:
        pass

    xml = '<var name="%s" type="%s" ' % (make_valid_xml_value(name),
                                         make_valid_xml_value(typeName))

    if type_qualifier:
        xmlQualifier = 'qualifier="%s"' % make_valid_xml_value(type_qualifier)
    else:
        xmlQualifier = ''

    if value:
        #cannot be too big... communication may not handle it.
        if len(value) > MAXIMUM_VARIABLE_REPRESENTATION_SIZE and doTrim:
            value = value[0:MAXIMUM_VARIABLE_REPRESENTATION_SIZE]
            value += '...'

        #fix to work with unicode values
        try:
            if not IS_PY3K:
                if isinstance(value, unicode):
                    value = value.encode('utf-8')
            else:
                if isinstance(value, bytes):
                    value = value.encode('utf-8')
        except TypeError:  #in java, unicode is a function
            pass

        xmlValue = ' value="%s"' % (make_valid_xml_value(quote(value,
                                                               '/>_= ')))
    else:
        xmlValue = ''

    if is_exception_on_eval:
        xmlCont = ' isErrorOnEval="True"'
    else:
        if resolver is not None:
            xmlCont = ' isContainer="True"'
        else:
            xmlCont = ''

    return ''.join(
        (xml, xmlQualifier, xmlValue, xmlCont, additionalInXml, ' />\n'))
コード例 #9
0
ファイル: pydevd_xml.py プロジェクト: vsajip/Pydev
def var_to_xml(val, name, doTrim=True, additional_in_xml=''):
    """ single variable or dictionary to xml representation """

    try:
        # This should be faster than isinstance (but we have to protect against not having a '__class__' attribute).
        is_exception_on_eval = val.__class__ == ExceptionOnEvaluate
    except:
        is_exception_on_eval = False

    if is_exception_on_eval:
        v = val.result
    else:
        v = val

    _type, typeName, resolver = get_type(v)
    type_qualifier = getattr(_type, "__module__", "")
    do_not_call_value_str = resolver is not None and resolver.use_value_repr_instead_of_str

    try:
        if hasattr(v, '__class__'):
            if v.__class__ == frame_type:
                value = pydevd_resolver.frameResolver.get_frame_name(v)

            elif v.__class__ in (list, tuple):
                if len(v) > 300:
                    value = '%s: %s' % (str(
                        v.__class__), '<Too big to print. Len: %s>' %
                                        (len(v), ))
                else:
                    value = '%s: %s' % (str(v.__class__), v)
            else:
                try:
                    cName = str(v.__class__)
                    if cName.find('.') != -1:
                        cName = cName.split('.')[-1]

                    elif cName.find(
                            "'"
                    ) != -1:  #does not have '.' (could be something like <type 'int'>)
                        cName = cName[cName.index("'") + 1:]

                    if cName.endswith("'>"):
                        cName = cName[:-2]
                except:
                    cName = str(v.__class__)

                if do_not_call_value_str:
                    value = '%s: %r' % (cName, v)
                else:
                    value = '%s: %s' % (cName, v)
        else:
            value = str(v)
    except:
        try:
            value = repr(v)
        except:
            value = 'Unable to get repr for %s' % v.__class__

    try:
        name = quote(name, '/>_= ')  #TODO: Fix PY-5834 without using quote
    except:
        pass

    xml = '<var name="%s" type="%s" ' % (make_valid_xml_value(name),
                                         make_valid_xml_value(typeName))

    if type_qualifier:
        xml_qualifier = 'qualifier="%s"' % make_valid_xml_value(type_qualifier)
    else:
        xml_qualifier = ''

    if value:
        #cannot be too big... communication may not handle it.
        if len(value) > MAXIMUM_VARIABLE_REPRESENTATION_SIZE and doTrim:
            value = value[0:MAXIMUM_VARIABLE_REPRESENTATION_SIZE]
            value += '...'

        #fix to work with unicode values
        try:
            if not IS_PY3K:
                if isinstance(value, unicode):
                    value = value.encode('utf-8')
            else:
                if isinstance(value, bytes):
                    value = value.encode('utf-8')
        except TypeError:  #in java, unicode is a function
            pass

        xml_value = ' value="%s"' % (make_valid_xml_value(quote(
            value, '/>_= ')))
    else:
        xml_value = ''

    if is_exception_on_eval:
        xml_container = ' isErrorOnEval="True"'
    else:
        if resolver is not None:
            xml_container = ' isContainer="True"'
        else:
            xml_container = ''

    return ''.join((xml, xml_qualifier, xml_value, xml_container,
                    additional_in_xml, ' />\n'))
コード例 #10
0
ファイル: pydevd_xml.py プロジェクト: gitrazr/filmkodi
def var_to_xml(val, name, doTrim=True, additionalInXml=''):
    """ single variable or dictionary to xml representation """

    is_exception_on_eval = isinstance(val, ExceptionOnEvaluate)

    if is_exception_on_eval:
        v = val.result
    else:
        v = val

    _type, typeName, resolver = get_type(v)

    do_not_call_value_str = False
    if isinstance(resolver, pydevd_resolver.djangoFormResolver.__class__):
        # do not call str() of Django form objects because has side effects and breaks self.errors
        do_not_call_value_str = True

    try:
        if hasattr(v, '__class__'):
            if v.__class__ == frame_type:
                value = pydevd_resolver.frameResolver.get_frame_name(v)

            elif v.__class__ in (list, tuple):
                if len(v) > 300:
                    value = '%s: %s' % (str(v.__class__), '<Too big to print. Len: %s>' % (len(v),))
                else:
                    value = '%s: %s' % (str(v.__class__), v)
            else:
                try:
                    cName = str(v.__class__)
                    if cName.find('.') != -1:
                        cName = cName.split('.')[-1]

                    elif cName.find("'") != -1: #does not have '.' (could be something like <type 'int'>)
                        cName = cName[cName.index("'") + 1:]

                    if cName.endswith("'>"):
                        cName = cName[:-2]
                except:
                    cName = str(v.__class__)

                if do_not_call_value_str:
                    value = '%s: %r' % (cName, v)
                else:
                    value = '%s: %s' % (cName, v)
        else:
            value = str(v)
    except:
        try:
            value = repr(v)
        except:
            value = 'Unable to get repr for %s' % v.__class__

    try:
        name = quote(name, '/>_= ') #TODO: Fix PY-5834 without using quote
    except:
        pass
    xml = '<var name="%s" type="%s"' % (make_valid_xml_value(name), make_valid_xml_value(typeName))

    if value:
        #cannot be too big... communication may not handle it.
        if len(value) > MAXIMUM_VARIABLE_REPRESENTATION_SIZE and doTrim:
            value = value[0:MAXIMUM_VARIABLE_REPRESENTATION_SIZE]
            value += '...'

        #fix to work with unicode values
        try:
            if not IS_PY3K:
                if isinstance(value, unicode):
                    value = value.encode('utf-8')
            else:
                if isinstance(value, bytes):
                    value = value.encode('utf-8')
        except TypeError: #in java, unicode is a function
            pass

        xmlValue = ' value="%s"' % (make_valid_xml_value(quote(value, '/>_= ')))
    else:
        xmlValue = ''

    if is_exception_on_eval:
        xmlCont = ' isErrorOnEval="True"'
    else:
        if resolver is not None:
            xmlCont = ' isContainer="True"'
        else:
            xmlCont = ''

    return ''.join((xml, xmlValue, xmlCont, additionalInXml, ' />\n'))
コード例 #11
0
ファイル: pydevd_xml.py プロジェクト: xplayr/specto
def var_to_xml(val, name, doTrim=True, additionalInXml=''):
    """ single variable or dictionary to xml representation """

    is_exception_on_eval = isinstance(val, ExceptionOnEvaluate)

    if is_exception_on_eval:
        v = val.result
    else:
        v = val

    _type, typeName, resolver = get_type(v)

    do_not_call_value_str = False
    if isinstance(resolver, pydevd_resolver.djangoFormResolver.__class__):
        # do not call str() of Django form objects because has side effects and breaks self.errors
        do_not_call_value_str = True

    try:
        if hasattr(v, '__class__'):
            if v.__class__ == frame_type:
                value = pydevd_resolver.frameResolver.get_frame_name(v)

            elif v.__class__ in (list, tuple):
                if len(v) > 300:
                    value = '%s: %s' % (str(
                        v.__class__), '<Too big to print. Len: %s>' %
                                        (len(v), ))
                else:
                    value = '%s: %s' % (str(v.__class__), v)
            else:
                try:
                    cName = str(v.__class__)
                    if cName.find('.') != -1:
                        cName = cName.split('.')[-1]

                    elif cName.find(
                            "'"
                    ) != -1:  #does not have '.' (could be something like <type 'int'>)
                        cName = cName[cName.index("'") + 1:]

                    if cName.endswith("'>"):
                        cName = cName[:-2]
                except:
                    cName = str(v.__class__)

                if do_not_call_value_str:
                    value = '%s: %r' % (cName, v)
                else:
                    value = '%s: %s' % (cName, v)
        else:
            value = str(v)
    except:
        try:
            value = repr(v)
        except:
            value = 'Unable to get repr for %s' % v.__class__

    try:
        name = quote(name, '/>_= ')  #TODO: Fix PY-5834 without using quote
    except:
        pass
    xml = '<var name="%s" type="%s"' % (make_valid_xml_value(name),
                                        make_valid_xml_value(typeName))

    if value:
        #cannot be too big... communication may not handle it.
        if len(value) > MAXIMUM_VARIABLE_REPRESENTATION_SIZE and doTrim:
            value = value[0:MAXIMUM_VARIABLE_REPRESENTATION_SIZE]
            value += '...'

        #fix to work with unicode values
        try:
            if not IS_PY3K:
                if isinstance(value, unicode):
                    value = value.encode('utf-8')
            else:
                if isinstance(value, bytes):
                    value = value.encode('utf-8')
        except TypeError:  #in java, unicode is a function
            pass

        xmlValue = ' value="%s"' % (make_valid_xml_value(quote(value,
                                                               '/>_= ')))
    else:
        xmlValue = ''

    if is_exception_on_eval:
        xmlCont = ' isErrorOnEval="True"'
    else:
        if resolver is not None:
            xmlCont = ' isContainer="True"'
        else:
            xmlCont = ''

    return ''.join((xml, xmlValue, xmlCont, additionalInXml, ' />\n'))
コード例 #12
0
def var_to_xml(val,
               name,
               doTrim=True,
               additional_in_xml='',
               evaluate_full_value=True,
               format='%s',
               user_type_renderers=None):
    """ single variable or dictionary to xml representation """

    try:
        # This should be faster than isinstance (but we have to protect against not having a '__class__' attribute).
        is_exception_on_eval = val.__class__ == ExceptionOnEvaluate
    except:
        is_exception_on_eval = False

    if is_exception_on_eval:
        v = val.result
    else:
        v = val

    _type, typeName, resolver = get_type(v)
    type_qualifier = getattr(_type, "__module__", "")

    type_renderer = None
    if user_type_renderers is not None:
        type_renderer = try_get_type_renderer_for_var(v, user_type_renderers)

    var_custom_string_repr = None
    value = None
    if not evaluate_full_value:
        value = DEFAULT_VALUES_DICT[LOAD_VALUES_POLICY]
    elif type_renderer is not None:
        var_custom_string_repr = type_renderer.evaluate_var_string_repr(v)
        value = var_custom_string_repr

    if value is None:
        value = _get_default_var_string_representation(v, _type, typeName,
                                                       format)

    try:
        name = quote(name, '/>_= ')  # TODO: Fix PY-5834 without using quote
    except:
        pass

    xml = '<var name="%s" type="%s" ' % (make_valid_xml_value(name),
                                         make_valid_xml_value(typeName))

    if type_qualifier:
        xml_qualifier = 'qualifier="%s"' % make_valid_xml_value(type_qualifier)
    else:
        xml_qualifier = ''

    # cannot be too big... communication may not handle it.
    if len(value) > MAXIMUM_VARIABLE_REPRESENTATION_SIZE and doTrim:
        value = value[0:MAXIMUM_VARIABLE_REPRESENTATION_SIZE]
        value += '...'

    # fix to work with unicode values
    try:
        if not IS_PY3K:
            if value.__class__ == unicode:  # @UndefinedVariable
                value = value.encode('utf-8')
        else:
            if value.__class__ == bytes:
                value = value.encode('utf-8')
    except TypeError:  # in java, unicode is a function
        pass

    if is_pandas_container(type_qualifier, typeName,
                           v) and var_custom_string_repr is None:
        value = pandas_to_str(v, typeName, value,
                              pydevd_resolver.MAX_ITEMS_TO_HANDLE)
    xml_value = ' value="%s"' % (make_valid_xml_value(quote(value, '/>_= ')))

    xml_shape = ''
    try:
        if should_evaluate_shape():
            if hasattr(v, 'shape') and not callable(v.shape):
                xml_shape = ' shape="%s"' % make_valid_xml_value(
                    str(tuple(v.shape)))
            elif hasattr(v, '__len__') and not is_string(v):
                xml_shape = ' shape="%s"' % make_valid_xml_value(
                    "%s" % str(len(v)))
    except:
        pass

    if is_exception_on_eval:
        xml_container = ' isErrorOnEval="True"'
    else:
        if resolver is not None:
            xml_container = ' isContainer="True"'
        else:
            xml_container = ''

    if type_renderer is not None:
        xml_type_renderer_id = 'typeRendererId="%s"' % make_valid_xml_value(
            type_renderer.to_type)
    else:
        xml_type_renderer_id = ''

    return ''.join((xml, xml_qualifier, xml_value, xml_container, xml_shape,
                    xml_type_renderer_id, additional_in_xml, ' />\n'))