当前位置: 首页>>代码示例>>Python>>正文


Python sax.SAXParseException方法代码示例

本文整理汇总了Python中xml.sax.SAXParseException方法的典型用法代码示例。如果您正苦于以下问题:Python sax.SAXParseException方法的具体用法?Python sax.SAXParseException怎么用?Python sax.SAXParseException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xml.sax的用法示例。


在下文中一共展示了sax.SAXParseException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_sax_parse_exception_str

# 需要导入模块: from xml import sax [as 别名]
# 或者: from xml.sax import SAXParseException [as 别名]
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))) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_sax.py

示例2: parse

# 需要导入模块: from xml import sax [as 别名]
# 或者: from xml.sax import SAXParseException [as 别名]
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
#
#------------------------------------------------------------------------ 
开发者ID:GenealogyCollective,项目名称:gprime,代码行数:20,代码来源:stylesheet.py

示例3: parse

# 需要导入模块: from xml import sax [as 别名]
# 或者: from xml.sax import SAXParseException [as 别名]
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
#
#------------------------------------------------------------------------- 
开发者ID:GenealogyCollective,项目名称:gprime,代码行数:21,代码来源:_book.py

示例4: parse

# 需要导入模块: from xml import sax [as 别名]
# 或者: from xml.sax import SAXParseException [as 别名]
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
#
#------------------------------------------------------------------------- 
开发者ID:GenealogyCollective,项目名称:gprime,代码行数:20,代码来源:_options.py

示例5: parse

# 需要导入模块: from xml import sax [as 别名]
# 或者: from xml.sax import SAXParseException [as 别名]
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
#
#------------------------------------------------------------------------- 
开发者ID:GenealogyCollective,项目名称:gprime,代码行数:19,代码来源:_options.py

示例6: compatibility_verbose

# 需要导入模块: from xml import sax [as 别名]
# 或者: from xml.sax import SAXParseException [as 别名]
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) 
开发者ID:usharesoft,项目名称:hammr,代码行数:20,代码来源:hammr.py

示例7: _create_client

# 需要导入模块: from xml import sax [as 别名]
# 或者: from xml.sax import SAXParseException [as 别名]
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) 
开发者ID:F5Networks,项目名称:bigsuds,代码行数:14,代码来源:bigsuds.py

示例8: test_expat_incomplete

# 需要导入模块: from xml import sax [as 别名]
# 或者: from xml.sax import SAXParseException [as 别名]
def test_expat_incomplete(self):
        parser = create_parser()
        parser.setContentHandler(ContentHandler()) # do nothing
        self.assertRaises(SAXParseException, parser.parse, StringIO("<foo>"))
        self.assertEqual(parser.getColumnNumber(), 5)
        self.assertEqual(parser.getLineNumber(), 1) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_sax.py

示例9: test_sf_1513611

# 需要导入模块: from xml import sax [as 别名]
# 或者: from xml.sax import SAXParseException [as 别名]
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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_sax.py

示例10: _check_descriptor_data

# 需要导入模块: from xml import sax [as 别名]
# 或者: from xml.sax import SAXParseException [as 别名]
def _check_descriptor_data(descriptor_data):
        try:
            data = base64.b64decode(descriptor_data).decode('utf-8')
        except binascii.Error:
            raise CSEContentsUnacceptable("The descriptor was not correctly base64 encoded.")

        try:
            g = Graph()
            g.parse(data=data, format="application/rdf+xml")
        except SAXParseException:
            raise CSEContentsUnacceptable("The descriptor attribute does not conform to the "
                                          "RDF/XML syntax as defined in RDF 1.1 XML Syntax.") 
开发者ID:OpenMTC,项目名称:OpenMTC,代码行数:14,代码来源:__init__.py

示例11: test_expat_incomplete

# 需要导入模块: from xml import sax [as 别名]
# 或者: from xml.sax import SAXParseException [as 别名]
def test_expat_incomplete(self):
        parser = create_parser()
        parser.setContentHandler(ContentHandler()) # do nothing
        self.assertRaises(SAXParseException, parser.parse, StringIO("<foo>")) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:6,代码来源:test_sax.py

示例12: do_soap_request

# 需要导入模块: from xml import sax [as 别名]
# 或者: from xml.sax import SAXParseException [as 别名]
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 
开发者ID:alesnav,项目名称:p2ptv-pi,代码行数:36,代码来源:upnp.py

示例13: assertXMLWellFormed

# 需要导入模块: from xml import sax [as 别名]
# 或者: from xml.sax import SAXParseException [as 别名]
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) 
开发者ID:jlachowski,项目名称:clonedigger,代码行数:12,代码来源:testlib.py

示例14: parseXmlFile

# 需要导入模块: from xml import sax [as 别名]
# 或者: from xml.sax import SAXParseException [as 别名]
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 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:15,代码来源:common.py

示例15: render

# 需要导入模块: from xml import sax [as 别名]
# 或者: from xml.sax import SAXParseException [as 别名]
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] 
开发者ID:pixelated,项目名称:pixelated-user-agent,代码行数:9,代码来源:login_resource.py


注:本文中的xml.sax.SAXParseException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。