示例#1
0
 def check_xml(self, content):
     if isXml(content):
         if self.get_opt('print'):
             print(content, end='')
         else:
             print(self.valid_xml_msg)
     else:
         self.failed = True
         if not self.get_opt('print'):
             if self.verbose > 2:
                 try:
                     ET.fromstring(content)
                 # Python 2.7 throws xml.etree.ElementTree.ParseError, but
                 # Python 2.6 throws xml.parsers.expat.ExpatError
                 # have to catch generic Exception to be able to handle both
                 except Exception as _:  # pylint: disable=broad-except
                     if not self.get_opt('print'):
                         print(_)
             die(self.invalid_xml_msg)
示例#2
0
 def check_xml(self, content):
     if isXml(content):
         if self.options.print:
             print(content, end='')
         else:
             print(self.valid_xml_msg)
     else:
         self.failed = True
         if not self.options.print:
             if self.get_verbose() > 2:
                 try:
                     ET.fromstring(content)
                 # Python 2.7 throws xml.etree.ElementTree.ParseError, but
                 # Python 2.6 throws xml.parsers.expat.ExpatError
                 # have to catch generic Exception to be able to handle both
                 except Exception as _:  # pylint: disable=broad-except
                     if not self.options.print:
                         print(_)
             die(self.invalid_xml_msg)