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

Class InternalSubsetExtractor

Lib/xml/dom/expatbuilder.py:852–893  ·  view source on GitHub ↗

XML processor which can rip out the internal document type subset.

Source from the content-addressed store, hash-verified

850 pass
851
852class InternalSubsetExtractor(ExpatBuilder):
853 """XML processor which can rip out the internal document type subset."""
854
855 subset = None
856
857 def getSubset(self):
858 """Return the internal subset as a string."""
859 return self.subset
860
861 def parseFile(self, file):
862 try:
863 ExpatBuilder.parseFile(self, file)
864 except ParseEscape:
865 pass
866
867 def parseString(self, string):
868 try:
869 ExpatBuilder.parseString(self, string)
870 except ParseEscape:
871 pass
872
873 def install(self, parser):
874 parser.StartDoctypeDeclHandler = self.start_doctype_decl_handler
875 parser.StartElementHandler = self.start_element_handler
876
877 def start_doctype_decl_handler(self, name, publicId, systemId,
878 has_internal_subset):
879 if has_internal_subset:
880 parser = self.getParser()
881 self.subset = []
882 parser.DefaultHandler = self.subset.append
883 parser.EndDoctypeDeclHandler = self.end_doctype_decl_handler
884 else:
885 raise ParseEscape()
886
887 def end_doctype_decl_handler(self):
888 s = ''.join(self.subset).replace('\r\n', '\n').replace('\r', '\n')
889 self.subset = s
890 raise ParseEscape()
891
892 def start_element_handler(self, name, attrs):
893 raise ParseEscape()
894
895
896def parse(file, namespaces=True):

Callers 1

_setup_subsetMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…