MCPcopy Index your code
hub / github.com/python/cpython / add_qname

Function add_qname

Lib/xml/etree/ElementTree.py:810–835  ·  view source on GitHub ↗
(qname)

Source from the content-addressed store, hash-verified

808 namespaces[default_namespace] = ""
809
810 def add_qname(qname):
811 # calculate serialized qname representation
812 try:
813 if qname[:1] == "{":
814 uri, tag = qname[1:].rsplit("}", 1)
815 prefix = namespaces.get(uri)
816 if prefix is None:
817 prefix = _namespace_map.get(uri)
818 if prefix is None:
819 prefix = "ns%d" % len(namespaces)
820 if prefix != "xml":
821 namespaces[uri] = prefix
822 if prefix:
823 qnames[qname] = "%s:%s" % (prefix, tag)
824 else:
825 qnames[qname] = tag # default element
826 else:
827 if default_namespace:
828 # FIXME: can this be handled in XML 1.0?
829 raise ValueError(
830 "cannot use non-qualified names with "
831 "default_namespace option"
832 )
833 qnames[qname] = qname
834 except TypeError:
835 _raise_serialization_error(qname)
836
837 # populate qname and namespaces table
838 for elem in elem.iter():

Callers 1

_namespacesFunction · 0.85

Calls 3

rsplitMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…