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

Function parseFragment

Lib/xml/dom/expatbuilder.py:925–942  ·  view source on GitHub ↗

Parse a fragment of a document, given the context from which it was originally extracted. context should be the parent of the node(s) which are in the fragment. 'file' may be either a file name or an open file object.

(file, context, namespaces=True)

Source from the content-addressed store, hash-verified

923
924
925def parseFragment(file, context, namespaces=True):
926 """Parse a fragment of a document, given the context from which it
927 was originally extracted. context should be the parent of the
928 node(s) which are in the fragment.
929
930 'file' may be either a file name or an open file object.
931 """
932 if namespaces:
933 builder = FragmentBuilderNS(context)
934 else:
935 builder = FragmentBuilder(context)
936
937 if isinstance(file, str):
938 with open(file, 'rb') as fp:
939 result = builder.parseFile(fp)
940 else:
941 result = builder.parseFile(file)
942 return result
943
944
945def parseFragmentString(string, context, namespaces=True):

Callers

nothing calls this directly

Calls 4

parseFileMethod · 0.95
FragmentBuilderNSClass · 0.85
FragmentBuilderClass · 0.85
openFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…