def parse_errata(data, force): """ Parse CentOS errata from https://cefs.steve-meier.de/ """ result = etree.XML(data) errata_xml = result.findall('*') elen = len(errata_xml) ptext = 'Processing {0!s} Errata:'.format(elen) progress_info_s.send(sender=None, ptext=ptext, plen=elen) for i, child in enumerate(errata_xml): progress_update_s.send(sender=None, index=i + 1) if not check_centos_release(child.findall('os_release')): continue e = parse_errata_tag(child.tag, child.attrib, force) if e is not None: parse_errata_children(e, child.getchildren())
def stringToXML(text): """Convert XML string into etree.Element.""" try: return etree.XML(text) except Exception: # TODO: # ExpatError: reference to invalid character number: line 1, column 62 # litmus fails, when xml is used instead of lxml # 18. propget............... FAIL (PROPFIND on `/temp/litmus/prop2': # Could not read status line: connection was closed by server) # text = <ns0:high-unicode xmlns:ns0="http://example.com/neon/litmus/">�� # </ns0:high-unicode> # t2 = text.encode("utf8") # return etree.XML(t2) print("Error parsing XML string. If lxml is not available, and unicode is involved, then " "installing lxml _may_ solve this issue.", file=sys.stderr) print("XML source:", text, file=sys.stderr) raise