Ejemplo n.º 1
0
    def fetch(self, url) -> Channel:
        response = requests.request('GET', url)
        root = defused_xml_parse(response.content)
        title = _get_text(root, './channel/title')
        icon = _get_text(root, './channel/image/url')
        image = _get_text(root, './channel/image/ur')
        url = _get_text(root, './channel/url')
        items = self._get_items(root)

        return Channel(
            title,
            icon,
            image,
            url,
            items
        )
Ejemplo n.º 2
0
    def fetch(self, url) -> Channel:
        response = requests.request('GET', url)
        root = defused_xml_parse(response.content)
        title = _get_text(root, './feed:title')
        icon = _get_text(root, './feed:icon')
        image = _get_text(root, './feed:logo')
        url = _get_attribute_text(root, './feed:link[@rel="alternate"]', 'href')
        items = self._get_items(root)

        return Channel(
            title,
            icon,
            image,
            url,
            items
        )
Ejemplo n.º 3
0
    def parse_file(cls, xml_file: t.IO[bytes]) -> 'CGJunit':
        """Parse a :class:`CGJunit` from an XML bytestream.

        :param xml_file: Path to the XML file with test run data to be parsed.
        :returns: The parsed test run data.
        :raises ParseError: When the XML could not be parsed, or does not
            follow the JUnit specification.
        """
        xml_data: ET.ElementTree = defused_xml_parse(xml_file)

        root_node = xml_data.getroot()
        if root_node.tag == 'testsuites':
            return cls([_CGJunitSuite.from_xml(node) for node in root_node])
        elif root_node.tag == 'testsuite':
            return cls([_CGJunitSuite.from_xml(root_node)])

        MalformedXmlData.ensure(False,
                                'Unknown root tag encountered, found: %s',
                                root_node.tag)
Ejemplo n.º 4
0
def parse_xml(xml_content):
    try:
        return defused_xml_parse(xml_content)
    except ParseError:
        raise FeedXMLError('Not a valid XML document')