Python xml.sax.handler.ContentHandler() Examples
The following are 10
code examples of xml.sax.handler.ContentHandler().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
xml.sax.handler
, or try the search function
.
Example #1
Source File: stylesheet.py From gprime with GNU General Public License v2.0 | 6 votes |
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
Example #2
Source File: _book.py From gprime with GNU General Public License v2.0 | 6 votes |
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
Example #3
Source File: svgfig.py From earthengine with MIT License | 5 votes |
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 ######################################################################
Example #4
Source File: _paper.py From gprime with GNU General Public License v2.0 | 5 votes |
def __init__(self, paper_list): handler.ContentHandler.__init__(self) self.paper_list = paper_list self.locator = None
Example #5
Source File: _options.py From gprime with GNU General Public License v2.0 | 5 votes |
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
Example #6
Source File: _filterparser.py From gprime with GNU General Public License v2.0 | 5 votes |
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
Example #7
Source File: __init__.py From python-overpy with MIT License | 5 votes |
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
Example #8
Source File: export.py From luscan-devel with GNU General Public License v2.0 | 5 votes |
def __init__(self, entry_cb=None): # Define the callbacks self.entry_cb = entry_cb # ContentHandler methods
Example #9
Source File: get_pypi_packages_metadata.py From depsy with MIT License | 5 votes |
def __init__(self): handler.ContentHandler.__init__(self) self.projects = set()
Example #10
Source File: config.py From uniconvertor with GNU Affero General Public License v3.0 | 5 votes |
def __init__(self, pref=None): handler.ContentHandler.__init__(self) self.key = None self.value = None self.pref = pref