MCPcopy
hub / github.com/pandas-dev/pandas / _parse_doc

Method _parse_doc

pandas/io/xml.py:628–659  ·  view source on GitHub ↗
(
        self, raw_doc: FilePath | ReadBuffer[bytes] | ReadBuffer[str]
    )

Source from the content-addressed store, hash-verified

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 """

Callers 1

parse_dataMethod · 0.95

Calls 3

get_data_from_filepathFunction · 0.85
parseFunction · 0.85
encodeMethod · 0.80

Tested by

no test coverage detected