MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / var_to_xml

Function var_to_xml

_pydevd_bundle/pydevd_xml.py:395–434  ·  view source on GitHub ↗

single variable or dictionary to xml representation

(val, name, trim_if_too_big=True, additional_in_xml="", evaluate_full_value=True)

Source from the content-addressed store, hash-verified

393
394
395def var_to_xml(val, name, trim_if_too_big=True, additional_in_xml="", evaluate_full_value=True):
396 """single variable or dictionary to xml representation"""
397
398 type_name, type_qualifier, is_exception_on_eval, resolver, value = get_variable_details(val, evaluate_full_value)
399
400 scope = get_var_scope(name, val, "", True)
401 try:
402 name = quote(name, "/>_= ") # TODO: Fix PY-5834 without using quote
403 except:
404 pass
405
406 xml = '<var name="%s" type="%s" ' % (make_valid_xml_value(name), make_valid_xml_value(type_name))
407
408 if type_qualifier:
409 xml_qualifier = 'qualifier="%s"' % make_valid_xml_value(type_qualifier)
410 else:
411 xml_qualifier = ""
412
413 if value:
414 # cannot be too big... communication may not handle it.
415 if len(value) > MAXIMUM_VARIABLE_REPRESENTATION_SIZE and trim_if_too_big:
416 value = value[0:MAXIMUM_VARIABLE_REPRESENTATION_SIZE]
417 value += "..."
418
419 xml_value = ' value="%s"' % (make_valid_xml_value(quote(value, "/>_= ")))
420 else:
421 xml_value = ""
422
423 if is_exception_on_eval:
424 xml_container = ' isErrorOnEval="True"'
425 else:
426 if resolver is not None:
427 xml_container = ' isContainer="True"'
428 else:
429 xml_container = ""
430
431 if scope:
432 return "".join((xml, xml_qualifier, xml_value, xml_container, additional_in_xml, ' scope="', scope, '"', " />\n"))
433 else:
434 return "".join((xml, xml_qualifier, xml_value, xml_container, additional_in_xml, " />\n"))

Callers 4

array_to_xmlFunction · 0.90
dataframe_to_xmlFunction · 0.90
frame_vars_to_xmlFunction · 0.85

Calls 4

get_var_scopeFunction · 0.90
get_variable_detailsFunction · 0.85
make_valid_xml_valueFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected