當前位置: 首頁>>代碼示例>>Python>>正文


Python pyexpat.error方法代碼示例

本文整理匯總了Python中pyexpat.error方法的典型用法代碼示例。如果您正苦於以下問題:Python pyexpat.error方法的具體用法?Python pyexpat.error怎麽用?Python pyexpat.error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pyexpat的用法示例。


在下文中一共展示了pyexpat.error方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _flush

# 需要導入模塊: import pyexpat [as 別名]
# 或者: from pyexpat import error [as 別名]
def _flush(self):
        if self._data:
            if self._last is not None:
                text = "".join(self._data)
                if self._tail:
                    assert self._last.tail is None, "internal error (tail)"
                    self._last.tail = text
                else:
                    assert self._last.text is None, "internal error (text)"
                    self._last.text = text
            self._data = []

    ##
    # Adds text to the current element.
    #
    # @param data A string.  This should be either an 8-bit string
    #    containing ASCII text, or a Unicode string. 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:19,代碼來源:ElementTree.py

示例2: __init__

# 需要導入模塊: import pyexpat [as 別名]
# 或者: from pyexpat import error [as 別名]
def __init__(self):
        import pyexpat
        self.DocumentStartEvent = None
        self.ElementEvent = None
        self.DocumentEndEvent = None
        self.error = pyexpat.error
        self.parser = pyexpat.ParserCreate("UTF-8", " ")
        self.parser.StartElementHandler = self._onStartElement
        self.parser.EndElementHandler = self._onEndElement
        self.parser.CharacterDataHandler = self._onCdata
        self.parser.StartNamespaceDeclHandler = self._onStartNamespace
        self.parser.EndNamespaceDeclHandler = self._onEndNamespace
        self.currElem = None
        self.defaultNsStack = ['']
        self.documentStarted = 0
        self.localPrefixes = {} 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:18,代碼來源:domish.py

示例3: __init__

# 需要導入模塊: import pyexpat [as 別名]
# 或者: from pyexpat import error [as 別名]
def __init__(self):
        import pyexpat
        self.DocumentStartEvent = None
        self.ElementEvent = None
        self.DocumentEndEvent = None
        self.error = pyexpat.error
        self.parser = pyexpat.ParserCreate("UTF-8", " ")
        self.parser.StartElementHandler = self._onStartElement
        self.parser.EndElementHandler = self._onEndElement
        self.parser.CharacterDataHandler = self._onCdata
        self.parser.StartNamespaceDeclHandler = self._onStartNamespace
        self.parser.EndNamespaceDeclHandler = self._onEndNamespace
        self.currElem = None
        self.defaultNsStack = ['']
        self.documentStarted = 0        
        self.localPrefixes = {} 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:18,代碼來源:domish.py

示例4: parse

# 需要導入模塊: import pyexpat [as 別名]
# 或者: from pyexpat import error [as 別名]
def parse(self, buffer):
        try:
            self.parser.Parse(buffer)
        except self.error as e:
            raise ParserError(str(e)) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:7,代碼來源:domish.py

示例5: _flush

# 需要導入模塊: import pyexpat [as 別名]
# 或者: from pyexpat import error [as 別名]
def _flush(self):
        if self._data:
            if self._last is not None:
                text = "".join(self._data)
                if self._tail:
                    assert self._last.tail is None, "internal error (tail)"
                    self._last.tail = text
                else:
                    assert self._last.text is None, "internal error (text)"
                    self._last.text = text
            self._data = [] 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:13,代碼來源:ElementTree.py

示例6: __init__

# 需要導入模塊: import pyexpat [as 別名]
# 或者: from pyexpat import error [as 別名]
def __init__(self, html=0, target=None, encoding=None):
        try:
            from xml.parsers import expat
        except ImportError:
            try:
                import pyexpat as expat
            except ImportError:
                raise ImportError(
                    "No module named expat; use SimpleXMLTreeBuilder instead"
                    )
        parser = expat.ParserCreate(encoding, "}")
        if target is None:
            target = TreeBuilder()
        # underscored names are provided for compatibility only
        self.parser = self._parser = parser
        self.target = self._target = target
        self._error = expat.error
        self._names = {} # name memo cache
        # main callbacks
        parser.DefaultHandlerExpand = self._default
        if hasattr(target, 'start'):
            parser.StartElementHandler = self._start
        if hasattr(target, 'end'):
            parser.EndElementHandler = self._end
        if hasattr(target, 'data'):
            parser.CharacterDataHandler = target.data
        # miscellaneous callbacks
        if hasattr(target, 'comment'):
            parser.CommentHandler = target.comment
        if hasattr(target, 'pi'):
            parser.ProcessingInstructionHandler = target.pi
        # Configure pyexpat: buffering, new-style attribute handling.
        parser.buffer_text = 1
        parser.ordered_attributes = 1
        parser.specified_attributes = 1
        self._doctype = None
        self.entity = {}
        try:
            self.version = "Expat %d.%d.%d" % expat.version_info
        except AttributeError:
            pass # unknown 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:43,代碼來源:ElementTree.py

示例7: parse

# 需要導入模塊: import pyexpat [as 別名]
# 或者: from pyexpat import error [as 別名]
def parse(self, buffer):
        try:
            self.parser.Parse(buffer)
        except self.error, e:
            raise ParserError, str(e) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:7,代碼來源:domish.py


注:本文中的pyexpat.error方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。