MCPcopy Index your code
hub / github.com/RustPython/RustPython / _getNSattrs

Method _getNSattrs

Lib/xml/dom/expatbuilder.py:818–845  ·  view source on GitHub ↗

Return string of namespace attributes from this element and ancestors.

(self)

Source from the content-addressed store, hash-verified

816 self._initNamespaces()
817
818 def _getNSattrs(self):
819 """Return string of namespace attributes from this element and
820 ancestors."""
821 # XXX This needs to be re-written to walk the ancestors of the
822 # context to build up the namespace information from
823 # declarations, elements, and attributes found in context.
824 # Otherwise we have to store a bunch more data on the DOM
825 # (though that *might* be more reliable -- not clear).
826 attrs = ""
827 context = self.context
828 L = []
829 while context:
830 if hasattr(context, '_ns_prefix_uri'):
831 for prefix, uri in context._ns_prefix_uri.items():
832 # add every new NS decl from context to L and attrs string
833 if prefix in L:
834 continue
835 L.append(prefix)
836 if prefix:
837 declname = "xmlns:" + prefix
838 else:
839 declname = "xmlns"
840 if attrs:
841 attrs = "%s\n %s='%s'" % (attrs, declname, uri)
842 else:
843 attrs = " %s='%s'" % (declname, uri)
844 context = context.parentNode
845 return attrs
846
847
848class ParseEscape(Exception):

Callers

nothing calls this directly

Calls 3

hasattrFunction · 0.85
itemsMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected