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


Python expat.ErrorString方法代码示例

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


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

示例1: feed

# 需要导入模块: from xml.parsers import expat [as 别名]
# 或者: from xml.parsers.expat import ErrorString [as 别名]
def feed(self, data, isFinal = 0):
        if not self._parsing:
            self.reset()
            self._parsing = 1
            self._cont_handler.startDocument()

        try:
            # The isFinal parameter is internal to the expat reader.
            # If it is set to true, expat will check validity of the entire
            # document. When feeding chunks, they are not normally final -
            # except when invoked from close.
            self._parser.Parse(data, isFinal)
        except expat.error as e:
            exc = SAXParseException(expat.ErrorString(e.code), e, self)
            # FIXME: when to invoke error()?
            self._err_handler.fatalError(exc) 
开发者ID:war-and-code,项目名称:jawfish,代码行数:18,代码来源:expatreader.py

示例2: feed

# 需要导入模块: from xml.parsers import expat [as 别名]
# 或者: from xml.parsers.expat import ErrorString [as 别名]
def feed(self, data, isFinal = 0):
        if not self._parsing:
            self.reset()
            self._parsing = 1
            self._cont_handler.startDocument()

        try:
            # The isFinal parameter is internal to the expat reader.
            # If it is set to true, expat will check validity of the entire
            # document. When feeding chunks, they are not normally final -
            # except when invoked from close.
            self._parser.Parse(data, isFinal)
        except expat.error, e:
            exc = SAXParseException(expat.ErrorString(e.code), e, self)
            # FIXME: when to invoke error()?
            self._err_handler.fatalError(exc) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:expatreader.py

示例3: test_parse_again

# 需要导入模块: from xml.parsers import expat [as 别名]
# 或者: from xml.parsers.expat import ErrorString [as 别名]
def test_parse_again(self):
        parser = expat.ParserCreate()
        file = StringIO.StringIO(data)
        parser.ParseFile(file)
        # Issue 6676: ensure a meaningful exception is raised when attempting
        # to parse more than one XML document per xmlparser instance,
        # a limitation of the Expat library.
        with self.assertRaises(expat.error) as cm:
            parser.ParseFile(file)
        self.assertEqual(expat.ErrorString(cm.exception.code),
                          expat.errors.XML_ERROR_FINISHED) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_pyexpat.py

示例4: test_error_code

# 需要导入模块: from xml.parsers import expat [as 别名]
# 或者: from xml.parsers.expat import ErrorString [as 别名]
def test_error_code(self):
        from xml.parsers import expat
        self.assertEqual(expat.ErrorString(self._get_error('foo').code),
                         expat.errors.XML_ERROR_SYNTAX) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_xml_etree.py

示例5: test_parse_again

# 需要导入模块: from xml.parsers import expat [as 别名]
# 或者: from xml.parsers.expat import ErrorString [as 别名]
def test_parse_again(self):
        parser = expat.ParserCreate()
        file = BytesIO(data)
        parser.ParseFile(file)
        # Issue 6676: ensure a meaningful exception is raised when attempting
        # to parse more than one XML document per xmlparser instance,
        # a limitation of the Expat library.
        with self.assertRaises(expat.error) as cm:
            parser.ParseFile(file)
        self.assertEqual(expat.ErrorString(cm.exception.code),
                          expat.errors.XML_ERROR_FINISHED) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:13,代码来源:test_pyexpat.py

示例6: _get_bugzilla_bug

# 需要导入模块: from xml.parsers import expat [as 别名]
# 或者: from xml.parsers.expat import ErrorString [as 别名]
def _get_bugzilla_bug(bug_id):
    """Fetch bug ``bug_id``.

    :param int bug_id: The ID of a bug in the Bugzilla database.
    :return: A FRIGGIN UNDOCUMENTED python-bugzilla THING.
    :raises BugFetchError: If an error occurs while fetching the bug. For
        example, a network timeout occurs or the bug does not exist.

    """
    # Is bug ``bug_id`` in the cache?
    if bug_id in _bugzilla:
        LOGGER.debug('Bugzilla bug {0} found in cache.'.format(bug_id))
    else:
        LOGGER.info('Bugzilla bug {0} not in cache. Fetching.'.format(bug_id))
        # Make a network connection to the Bugzilla server.
        try:
            bz_conn = bugzilla.RHBugzilla()
            bz_conn.connect(BUGZILLA_URL)
        except (TypeError, ValueError):
            raise BugFetchError(
                'Could not connect to {0}'.format(BUGZILLA_URL)
            )
        # Fetch the bug and place it in the cache.
        try:
            _bugzilla[bug_id] = bz_conn.getbugsimple(bug_id)
        except Fault as err:
            raise BugFetchError(
                'Could not fetch bug. Error: {0}'.format(err.faultString)
            )
        except ExpatError as err:
            raise BugFetchError(
                'Could not interpret bug. Error: {0}'
                .format(ErrorString(err.code))
            )

    return _bugzilla[bug_id] 
开发者ID:SatelliteQE,项目名称:automation-tools,代码行数:38,代码来源:bz.py


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