(
self, raw_doc: FilePath | ReadBuffer[bytes] | ReadBuffer[str]
)
| 626 | ) |
| 627 | |
| 628 | def _parse_doc( |
| 629 | self, raw_doc: FilePath | ReadBuffer[bytes] | ReadBuffer[str] |
| 630 | ) -> etree._Element: |
| 631 | from lxml.etree import ( |
| 632 | XMLParser, |
| 633 | fromstring, |
| 634 | parse, |
| 635 | ) |
| 636 | |
| 637 | handle_data = get_data_from_filepath( |
| 638 | filepath_or_buffer=raw_doc, |
| 639 | encoding=self.encoding, |
| 640 | compression=self.compression, |
| 641 | storage_options=self.storage_options, |
| 642 | ) |
| 643 | |
| 644 | with handle_data as xml_data: |
| 645 | curr_parser = XMLParser(encoding=self.encoding) |
| 646 | |
| 647 | if isinstance(xml_data, io.StringIO): |
| 648 | if self.encoding is None: |
| 649 | raise TypeError( |
| 650 | "Can not pass encoding None when input is StringIO." |
| 651 | ) |
| 652 | |
| 653 | document = fromstring( |
| 654 | xml_data.getvalue().encode(self.encoding), parser=curr_parser |
| 655 | ) |
| 656 | else: |
| 657 | document = parse(xml_data, parser=curr_parser) |
| 658 | |
| 659 | return document |
| 660 | |
| 661 | def _transform_doc(self) -> etree._XSLTResultTree: |
| 662 | """ |
no test coverage detected