本文整理汇总了Python中handler.ContentHandler方法的典型用法代码示例。如果您正苦于以下问题:Python handler.ContentHandler方法的具体用法?Python handler.ContentHandler怎么用?Python handler.ContentHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类handler
的用法示例。
在下文中一共展示了handler.ContentHandler方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _qname
# 需要导入模块: import handler [as 别名]
# 或者: from handler import ContentHandler [as 别名]
def _qname(self, name):
"""Builds a qualified name from a (ns_url, localname) pair"""
if name[0]:
# Per http://www.w3.org/XML/1998/namespace, The 'xml' prefix is
# bound by definition to http://www.w3.org/XML/1998/namespace. It
# does not need to be declared and will not usually be found in
# self._current_context.
if 'http://www.w3.org/XML/1998/namespace' == name[0]:
return 'xml:' + name[1]
# The name is in a non-empty namespace
prefix = self._current_context[name[0]]
if prefix:
# If it is not the default namespace, prepend the prefix
return prefix + ":" + name[1]
# Return the unqualified name
return name[1]
# ContentHandler methods
示例2: __init__
# 需要导入模块: import handler [as 别名]
# 或者: from handler import ContentHandler [as 别名]
def __init__(self):
self._cont_handler = handler.ContentHandler()
self._dtd_handler = handler.DTDHandler()
self._ent_handler = handler.EntityResolver()
self._err_handler = handler.ErrorHandler()
示例3: getContentHandler
# 需要导入模块: import handler [as 别名]
# 或者: from handler import ContentHandler [as 别名]
def getContentHandler(self):
"Returns the current ContentHandler."
return self._cont_handler
示例4: __init__
# 需要导入模块: import handler [as 别名]
# 或者: from handler import ContentHandler [as 别名]
def __init__(self, out=None, encoding="iso-8859-1"):
if out is None:
import sys
out = sys.stdout
handler.ContentHandler.__init__(self)
self._out = out
self._ns_contexts = [{}] # contains uri -> prefix dicts
self._current_context = self._ns_contexts[-1]
self._undeclared_ns_maps = []
self._encoding = encoding
示例5: warning
# 需要导入模块: import handler [as 别名]
# 或者: from handler import ContentHandler [as 别名]
def warning(self, exception):
self._err_handler.warning(exception)
# ContentHandler methods
示例6: __init__
# 需要导入模块: import handler [as 别名]
# 或者: from handler import ContentHandler [as 别名]
def __init__(self, out=None, encoding="iso-8859-1"):
handler.ContentHandler.__init__(self)
out = _gettextwriter(out, encoding)
self._write = out.write
self._flush = out.flush
self._ns_contexts = [{}] # contains uri -> prefix dicts
self._current_context = self._ns_contexts[-1]
self._undeclared_ns_maps = []
self._encoding = encoding