Python xml.sax.SAXParseException() Examples
The following are 30
code examples of xml.sax.SAXParseException().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
xml.sax
, or try the search function
.
Example #1
Source File: test_sax.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def test_sax_parse_exception_str(self): # pass various values from a locator to the SAXParseException to # make sure that the __str__() doesn't fall apart when None is # passed instead of an integer line and column number # # use "normal" values for the locator: str(SAXParseException("message", None, self.DummyLocator(1, 1))) # use None for the line number: str(SAXParseException("message", None, self.DummyLocator(None, 1))) # use None for the column number: str(SAXParseException("message", None, self.DummyLocator(1, None))) # use None for both: str(SAXParseException("message", None, self.DummyLocator(None, None)))
Example #2
Source File: test_sax.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_sax_parse_exception_str(self): # pass various values from a locator to the SAXParseException to # make sure that the __str__() doesn't fall apart when None is # passed instead of an integer line and column number # # use "normal" values for the locator: str(SAXParseException("message", None, self.DummyLocator(1, 1))) # use None for the line number: str(SAXParseException("message", None, self.DummyLocator(None, 1))) # use None for the column number: str(SAXParseException("message", None, self.DummyLocator(1, None))) # use None for both: str(SAXParseException("message", None, self.DummyLocator(None, None)))
Example #3
Source File: test_sax.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_sax_parse_exception_str(self): # pass various values from a locator to the SAXParseException to # make sure that the __str__() doesn't fall apart when None is # passed instead of an integer line and column number # # use "normal" values for the locator: str(SAXParseException("message", None, self.DummyLocator(1, 1))) # use None for the line number: str(SAXParseException("message", None, self.DummyLocator(None, 1))) # use None for the column number: str(SAXParseException("message", None, self.DummyLocator(1, None))) # use None for both: str(SAXParseException("message", None, self.DummyLocator(None, None)))
Example #4
Source File: hammr.py From hammr with Apache License 2.0 | 6 votes |
def compatibility_verbose(self): try: compatible, serviceStatusVersion = checkUForgeCompatible(api) if not compatible: printer.out("Sorry but this version of Hammr (version = '" + str( constants.VERSION) + "') is not compatible with the version of UForge (version = '" + str( serviceStatusVersion) + "').", printer.ERROR) printer.out( "Please refer to 'Install Compatibility' section in the documentation to learn how to install a compatible version of Hammr.", printer.ERROR) sys.exit(2) except (SAXParseException, RequestException): printer.out("Cannot reached the UForge server. Please check the provided URL.", printer.ERROR) sys.exit(2) except Exception as e: hammr_utils.print_uforge_exception(e) sys.exit(2)
Example #5
Source File: test_sax.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_sax_parse_exception_str(self): # pass various values from a locator to the SAXParseException to # make sure that the __str__() doesn't fall apart when None is # passed instead of an integer line and column number # # use "normal" values for the locator: str(SAXParseException("message", None, self.DummyLocator(1, 1))) # use None for the line number: str(SAXParseException("message", None, self.DummyLocator(None, 1))) # use None for the column number: str(SAXParseException("message", None, self.DummyLocator(1, None))) # use None for both: str(SAXParseException("message", None, self.DummyLocator(None, None)))
Example #6
Source File: _options.py From gprime with GNU General Public License v2.0 | 6 votes |
def parse(self): """ Loads the OptionList from the associated file, if it exists. """ try: if os.path.isfile(self.filename): parser = make_parser() parser.setContentHandler(OptionParser(self)) parser.parse(self.filename) except (IOError, OSError, SAXParseException): pass #------------------------------------------------------------------------- # # OptionParser # #-------------------------------------------------------------------------
Example #7
Source File: test_sax.py From oss-ftp with MIT License | 6 votes |
def test_sax_parse_exception_str(self): # pass various values from a locator to the SAXParseException to # make sure that the __str__() doesn't fall apart when None is # passed instead of an integer line and column number # # use "normal" values for the locator: str(SAXParseException("message", None, self.DummyLocator(1, 1))) # use None for the line number: str(SAXParseException("message", None, self.DummyLocator(None, 1))) # use None for the column number: str(SAXParseException("message", None, self.DummyLocator(1, None))) # use None for both: str(SAXParseException("message", None, self.DummyLocator(None, None)))
Example #8
Source File: _options.py From gprime with GNU General Public License v2.0 | 6 votes |
def parse(self): """ Loads the :class:`OptionList` from the associated file, if it exists. """ try: if os.path.isfile(self.filename): parser = make_parser() parser.setContentHandler(DocOptionParser(self)) with open(self.filename, encoding="utf-8") as the_file: parser.parse(the_file) except (IOError, OSError, SAXParseException): pass #------------------------------------------------------------------------ # # DocOptionParser class # #------------------------------------------------------------------------
Example #9
Source File: stylesheet.py From gprime with GNU General Public License v2.0 | 6 votes |
def parse(self): """ Loads the StyleSheets from the associated file, if it exists. """ try: if os.path.isfile(self.__file): parser = make_parser() parser.setContentHandler(SheetParser(self)) with open(self.__file) as the_file: parser.parse(the_file) except (IOError, OSError, SAXParseException): pass #------------------------------------------------------------------------ # # StyleSheet # #------------------------------------------------------------------------
Example #10
Source File: _book.py From gprime with GNU General Public License v2.0 | 6 votes |
def parse(self): """ Loads the BookList from the associated file, if it exists. """ try: parser = make_parser() parser.setContentHandler(BookParser(self, self.dbase)) with open(self.file) as the_file: parser.parse(the_file) except (IOError, OSError, ValueError, SAXParseException, KeyError, AttributeError): LOG.debug("Failed to parse book list", exc_info=True) #------------------------------------------------------------------------- # # BookParser # #-------------------------------------------------------------------------
Example #11
Source File: _options.py From gprime with GNU General Public License v2.0 | 6 votes |
def parse(self): """ Loads the :class:`OptionList` from the associated file, if it exists. """ try: if os.path.isfile(self.filename): parser = make_parser() parser.setContentHandler(OptionParser(self)) with open(self.filename, encoding="utf-8") as the_file: parser.parse(the_file) except (IOError, OSError, SAXParseException): pass #------------------------------------------------------------------------- # # OptionParser # #-------------------------------------------------------------------------
Example #12
Source File: test_sax.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_expat_incomplete(self): parser = create_parser() parser.setContentHandler(ContentHandler()) # do nothing self.assertRaises(SAXParseException, parser.parse, StringIO("<foo>"))
Example #13
Source File: upnp.py From p2ptv-pi with MIT License | 5 votes |
def do_soap_request(self, methodname, port = -1, iproto = 'TCP', internalip = None): for location, services in self.services.iteritems(): for service in services: if service['type'] in UPNP_WANTED_SERVICETYPES: o = urlparse(location) endpoint = o[0] + '://' + o[1] + service['url'] if DEBUG: log('upnp::do_soap_request: methodname', methodname, 'endpoint', endpoint, 'port', port, 'iproto', iproto, 'internalip', internalip) headers, body = self.create_soap_request(methodname, port, iproto=iproto, internalip=internalip) if DEBUG: log('upnp::do_soap_request: headers', headers) log('upnp::do_soap_request: body', body) try: req = urllib2.Request(url=endpoint, data=body, headers=headers) f = urllib2.urlopen(req) resp = f.read() except urllib2.HTTPError as e: resp = e.fp.read() if DEBUG: print_exc() srch = SOAPResponseContentHandler(methodname) if DEBUG: log('upnp::do_soap_request: method', methodname, 'response', resp) try: srch.parse(resp) except sax.SAXParseException as e: se = srch.get_error() if se is None: srch.set_error(str(e)) except Exception as e: srch.set_error(str(e)) yield srch
Example #14
Source File: test_sax.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_sf_1513611(self): # Bug report: http://www.python.org/sf/1513611 sio = StringIO("invalid") parser = make_parser() from xml.sax import SAXParseException self.assertRaises(SAXParseException, parser.parse, sio)
Example #15
Source File: login_resource.py From pixelated-user-agent with GNU Affero General Public License v3.0 | 5 votes |
def render(self, request): try: return super(DisclaimerElement, self).render(request) except SAXParseException: return ["Invalid XML template format for %s." % self._banner_filename] except IOError: return ["Disclaimer banner file %s could not be read or does not exit." % self._banner_filename]
Example #16
Source File: common.py From POC-EXP with GNU General Public License v3.0 | 5 votes |
def parseXmlFile(xmlFile, handler): """ Parses XML file by a given handler """ try: with contextlib.closing(StringIO(readCachedFileContent(xmlFile))) as stream: parse(stream, handler) except (SAXParseException, UnicodeError), ex: errMsg = "something seems to be wrong with " errMsg += "the file '%s' ('%s'). Please make " % (xmlFile, ex) errMsg += "sure that you haven't made any changes to it" raise SqlmapInstallationException, errMsg
Example #17
Source File: test_sax.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_expat_incomplete(self): parser = create_parser() parser.setContentHandler(ContentHandler()) # do nothing self.assertRaises(SAXParseException, parser.parse, StringIO("<foo>"))
Example #18
Source File: test_sax.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_sf_1513611(self): # Bug report: http://www.python.org/sf/1513611 sio = StringIO("invalid") parser = make_parser() from xml.sax import SAXParseException self.assertRaises(SAXParseException, parser.parse, sio)
Example #19
Source File: common.py From EasY_HaCk with Apache License 2.0 | 5 votes |
def parseXmlFile(xmlFile, handler): """ Parses XML file by a given handler """ try: with contextlib.closing(StringIO(readCachedFileContent(xmlFile))) as stream: parse(stream, handler) except (SAXParseException, UnicodeError), ex: errMsg = "something appears to be wrong with " errMsg += "the file '%s' ('%s'). Please make " % (xmlFile, getSafeExString(ex)) errMsg += "sure that you haven't made any changes to it" raise SqlmapInstallationException(errMsg)
Example #20
Source File: test_sax.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_expat_incomplete(self): parser = create_parser() parser.setContentHandler(ContentHandler()) # do nothing self.assertRaises(SAXParseException, parser.parse, StringIO("<foo>"))
Example #21
Source File: test_sax.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_sf_1513611(self): # Bug report: http://www.python.org/sf/1513611 sio = StringIO("invalid") parser = make_parser() from xml.sax import SAXParseException self.assertRaises(SAXParseException, parser.parse, sio)
Example #22
Source File: common.py From NoobSec-Toolkit with GNU General Public License v2.0 | 5 votes |
def parseXmlFile(xmlFile, handler): """ Parses XML file by a given handler """ try: with contextlib.closing(StringIO(readCachedFileContent(xmlFile))) as stream: parse(stream, handler) except (SAXParseException, UnicodeError), ex: errMsg = "something seems to be wrong with " errMsg += "the file '%s' ('%s'). Please make " % (xmlFile, ex) errMsg += "sure that you haven't made any changes to it" raise SqlmapInstallationException, errMsg
Example #23
Source File: common.py From NoobSec-Toolkit with GNU General Public License v2.0 | 5 votes |
def parseXmlFile(xmlFile, handler): """ Parses XML file by a given handler """ try: with contextlib.closing(StringIO(readCachedFileContent(xmlFile))) as stream: parse(stream, handler) except (SAXParseException, UnicodeError), ex: errMsg = "something seems to be wrong with " errMsg += "the file '%s' ('%s'). Please make " % (xmlFile, ex) errMsg += "sure that you haven't made any changes to it" raise SqlmapInstallationException, errMsg
Example #24
Source File: testlib.py From clonedigger with GNU General Public License v3.0 | 5 votes |
def assertXMLWellFormed(self, stream, msg=None): """asserts the XML stream is well-formed (no DTD conformance check)""" from xml.sax import make_parser, SAXParseException parser = make_parser() try: parser.parse(stream) except SAXParseException: if msg is None: msg = 'XML stream not well formed' self.fail(msg)
Example #25
Source File: bigsuds.py From bigsuds with MIT License | 5 votes |
def _create_client(self, wsdl_name): try: client = get_client(self._hostname, wsdl_name, self._username, self._password, self._cachedir, self._verify, self._timeout,self._port) except SAXParseException as e: raise ParseError('%s\nFailed to parse wsdl. Is "%s" a valid ' 'namespace?' % (e, wsdl_name)) # One situation that raises TransportError is when credentials are bad. except (URLError, TransportError) as e: raise ConnectionError(str(e)) return self._create_client_wrapper(client, wsdl_name)
Example #26
Source File: test_sax.py From oss-ftp with MIT License | 5 votes |
def test_sf_1513611(self): # Bug report: http://www.python.org/sf/1513611 sio = StringIO("invalid") parser = make_parser() from xml.sax import SAXParseException self.assertRaises(SAXParseException, parser.parse, sio)
Example #27
Source File: test_sax.py From oss-ftp with MIT License | 5 votes |
def test_expat_incomplete(self): parser = create_parser() parser.setContentHandler(ContentHandler()) # do nothing self.assertRaises(SAXParseException, parser.parse, StringIO("<foo>"))
Example #28
Source File: test_sax.py From BinderFilter with MIT License | 5 votes |
def test_sf_1513611(self): # Bug report: http://www.python.org/sf/1513611 sio = StringIO("invalid") parser = make_parser() from xml.sax import SAXParseException self.assertRaises(SAXParseException, parser.parse, sio)
Example #29
Source File: test_sax.py From BinderFilter with MIT License | 5 votes |
def test_sax_parse_exception_str(self): # pass various values from a locator to the SAXParseException to # make sure that the __str__() doesn't fall apart when None is # passed instead of an integer line and column number # # use "normal" values for the locator: str(SAXParseException("message", None, self.DummyLocator(1, 1))) # use None for the line number: str(SAXParseException("message", None, self.DummyLocator(None, 1))) # use None for the column number: str(SAXParseException("message", None, self.DummyLocator(1, None))) # use None for both: str(SAXParseException("message", None, self.DummyLocator(None, None)))
Example #30
Source File: test_sax.py From BinderFilter with MIT License | 5 votes |
def test_expat_incomplete(self): parser = create_parser() parser.setContentHandler(ContentHandler()) # do nothing self.assertRaises(SAXParseException, parser.parse, StringIO("<foo>"))