當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。