本文整理汇总了Python中xml.sax.handler.ContentHandler方法的典型用法代码示例。如果您正苦于以下问题:Python handler.ContentHandler方法的具体用法?Python handler.ContentHandler怎么用?Python handler.ContentHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xml.sax.handler
的用法示例。
在下文中一共展示了handler.ContentHandler方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from xml.sax import handler [as 别名]
# 或者: from xml.sax.handler import ContentHandler [as 别名]
def __init__(self, sheetlist):
"""
Create a SheetParser class that populates the passed StyleSheetList
class.
sheetlist - :class:`StyleSheetList` instance to be loaded from the file.
"""
handler.ContentHandler.__init__(self)
self.sheetlist = sheetlist
self.f = None
self.p = None
self.s = None
self.t = None
self.columns_widths = []
self.sheet_name = None
self.style_name = None
示例2: __init__
# 需要导入模块: from xml.sax import handler [as 别名]
# 或者: from xml.sax.handler import ContentHandler [as 别名]
def __init__(self, booklist, dbase):
"""
Create a BookParser class that populates the passed booklist.
booklist: BookList to be loaded from the file.
"""
handler.ContentHandler.__init__(self)
self.dbase = dbase
self.booklist = booklist
self.book = None
self.item = None
self.option = None
self.an_opt_name = None
self.an_opt_value = None
self.style = None
self.bname = None
self.iname = None
self.dbname = None
self.b_p_name = None
self.b_p_orient = None
self.b_p_metric = None
self.b_p_size = None
self.b_p_margins = None
self.b_p_format = None
self.b_p_output = None
示例3: __init__
# 需要导入模块: from xml.sax import handler [as 别名]
# 或者: from xml.sax.handler import ContentHandler [as 别名]
def __init__(self, paper_list):
handler.ContentHandler.__init__(self)
self.paper_list = paper_list
self.locator = None
示例4: __init__
# 需要导入模块: from xml.sax import handler [as 别名]
# 或者: from xml.sax.handler import ContentHandler [as 别名]
def __init__(self, collection):
"""
Create a OptionParser class that populates the passed collection.
collection: OptionListCollection to be loaded from the file.
"""
handler.ContentHandler.__init__(self)
self.collection = collection
self.mname = None
self.option_list = None
self.oname = None
self.odict = None
self.an_o = None
self.list_class = OptionList
示例5: __init__
# 需要导入模块: from xml.sax import handler [as 别名]
# 或者: from xml.sax.handler import ContentHandler [as 别名]
def __init__(self, gfilter_list):
handler.ContentHandler.__init__(self)
self.gfilter_list = gfilter_list
self.f = None
self.r = None
self.a = []
self.cname = None
self.namespace = 'Person'
self.use_regex = False
示例6: __init__
# 需要导入模块: from xml.sax import handler [as 别名]
# 或者: from xml.sax.handler import ContentHandler [as 别名]
def __init__(self, result):
"""
:param result: Append results to this result set.
:type result: overpy.Result
"""
handler.ContentHandler.__init__(self)
self._result = result
self._curr = {}
#: Current relation member object
self.cur_relation_member = None
示例7: __init__
# 需要导入模块: from xml.sax import handler [as 别名]
# 或者: from xml.sax.handler import ContentHandler [as 别名]
def __init__(self, entry_cb=None):
# Define the callbacks
self.entry_cb = entry_cb
# ContentHandler methods
示例8: __init__
# 需要导入模块: from xml.sax import handler [as 别名]
# 或者: from xml.sax.handler import ContentHandler [as 别名]
def __init__(self):
handler.ContentHandler.__init__(self)
self.projects = set()
示例9: __init__
# 需要导入模块: from xml.sax import handler [as 别名]
# 或者: from xml.sax.handler import ContentHandler [as 别名]
def __init__(self, pref=None):
handler.ContentHandler.__init__(self)
self.key = None
self.value = None
self.pref = pref
示例10: load_stream
# 需要导入模块: from xml.sax import handler [as 别名]
# 或者: from xml.sax.handler import ContentHandler [as 别名]
def load_stream(stream):
"""Loads an SVG image from a stream (can be a string or a file object)."""
from xml.sax import handler, make_parser
from xml.sax.handler import feature_namespaces, feature_external_ges, feature_external_pes
class ContentHandler(handler.ContentHandler):
def __init__(self):
self.stack = []
self.output = None
self.all_whitespace = re.compile("^\s*$")
def startElement(self, name, attr):
s = SVG(name)
s.attr = dict(attr.items())
if len(self.stack) > 0:
last = self.stack[-1]
last.sub.append(s)
self.stack.append(s)
def characters(self, ch):
if not isinstance(ch, basestring) or self.all_whitespace.match(ch) == None:
if len(self.stack) > 0:
last = self.stack[-1]
if len(last.sub) > 0 and isinstance(last.sub[-1], basestring):
last.sub[-1] = last.sub[-1] + "\n" + ch
else:
last.sub.append(ch)
def endElement(self, name):
if len(self.stack) > 0:
last = self.stack[-1]
if isinstance(last, SVG) and last.t == "style" and "type" in last.attr and last.attr["type"] == "text/css" and len(last.sub) == 1 and isinstance(last.sub[0], basestring):
last.sub[0] = "<![CDATA[\n" + last.sub[0] + "]]>"
self.output = self.stack.pop()
ch = ContentHandler()
parser = make_parser()
parser.setContentHandler(ch)
parser.setFeature(feature_namespaces, 0)
parser.setFeature(feature_external_ges, 0)
parser.parse(stream)
return ch.output
######################################################################