Parse a document from a file object, returning the document node.
(self, file)
| 195 | parser.AttlistDeclHandler = self.attlist_decl_handler |
| 196 | |
| 197 | def parseFile(self, file): |
| 198 | """Parse a document from a file object, returning the document |
| 199 | node.""" |
| 200 | parser = self.getParser() |
| 201 | first_buffer = True |
| 202 | try: |
| 203 | while buffer := file.read(16*1024): |
| 204 | parser.Parse(buffer, False) |
| 205 | if first_buffer and self.document.documentElement: |
| 206 | self._setup_subset(buffer) |
| 207 | first_buffer = False |
| 208 | parser.Parse(b"", True) |
| 209 | except ParseEscape: |
| 210 | pass |
| 211 | doc = self.document |
| 212 | self.reset() |
| 213 | self._parser = None |
| 214 | return doc |
| 215 | |
| 216 | def parseString(self, string): |
| 217 | """Parse a document from a string, returning the document node.""" |
no test coverage detected