/usr/lib/python2.6/site-packages/tablib/packages/odf3
NameSizeModeActions
anim.py18720644editdlrm
anim.pyc27240644editdlrm
attrconverters.py682100644editdlrm
attrconverters.pyc573550644editdlrm
chart.py26360644editdlrm
chart.pyc46240644editdlrm
config.py14200644editdlrm
config.pyc13910644editdlrm
dc.py22250644editdlrm
dc.pyc14640644editdlrm
dr3d.py14480644editdlrm
dr3d.pyc15240644editdlrm
draw.py55900644editdlrm
draw.pyc103430644editdlrm
easyliststyle.py37730644editdlrm
easyliststyle.pyc23120644editdlrm
element.py204730755editdlrm
element.pyc222500644editdlrm
elementtypes.py99330755editdlrm
elementtypes.pyc87290644editdlrm
form.py32700644editdlrm
form.pyc63900644editdlrm
grammar.py1933880644editdlrm
grammar.pyc1064580644editdlrm
load.py39630755editdlrm
load.pyc34090644editdlrm
manifest.py13890755editdlrm
manifest.pyc13440644editdlrm
math.py10680644editdlrm
math.pyc4590644editdlrm
meta.py21380644editdlrm
meta.pyc32430644editdlrm
namespaces.py39430644editdlrm
namespaces.pyc33140644editdlrm
number.py31370644editdlrm
number.pyc57430644editdlrm
odf2moinmoin.py181920644editdlrm
odf2moinmoin.pyc187740644editdlrm
odf2xhtml.py650580755editdlrm
odf2xhtml.pyc646200644editdlrm
odfmanifest.py35700755editdlrm
odfmanifest.pyc40720644editdlrm
office.py33460644editdlrm
office.pyc58950644editdlrm
opendocument.py259070644editdlrm
opendocument.pyc255300644editdlrm
presentation.py27160644editdlrm
presentation.pyc45550644editdlrm
script.py11060644editdlrm
script.pyc4840644editdlrm
style.py46720644editdlrm
style.pyc90620644editdlrm
svg.py17900644editdlrm
svg.pyc24060644editdlrm
table.py94080644editdlrm
table.pyc205930644editdlrm
teletype.py51810644editdlrm
teletype.pyc44600644editdlrm
text.py172150644editdlrm
text.pyc391260644editdlrm
thumbnail.py317360755editdlrm
thumbnail.pyc318640644editdlrm
userfield.py53940755editdlrm
userfield.pyc51590644editdlrm
xforms.py12330644editdlrm
xforms.pyc8730644editdlrm
__init__.py00644editdlrm
__init__.pyc1480644editdlrm
Edit: /usr/lib/python2.6/site-packages/tablib/packages/odf3/load.py (3963B)
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright (C) 2007-2008 Søren Roug, European Environment Agency # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # Contributor(s): # # This script is to be embedded in opendocument.py later # The purpose is to read an ODT/ODP/ODS file and create the datastructure # in memory. The user should then be able to make operations and then save # the structure again. from xml.sax import make_parser,handler from xml.sax.xmlreader import InputSource import xml.sax.saxutils from .element import Element from .namespaces import OFFICENS from io import StringIO # # Parse the XML files # class LoadParser(handler.ContentHandler): """ Extract headings from content.xml of an ODT file """ triggers = ( (OFFICENS, 'automatic-styles'), (OFFICENS, 'body'), (OFFICENS, 'font-face-decls'), (OFFICENS, 'master-styles'), (OFFICENS, 'meta'), (OFFICENS, 'scripts'), (OFFICENS, 'settings'), (OFFICENS, 'styles') ) def __init__(self, document): self.doc = document self.data = [] self.level = 0 self.parse = False def characters(self, data): if self.parse == False: return self.data.append(data) def startElementNS(self, tag, qname, attrs): if tag in self.triggers: self.parse = True if self.doc._parsing != "styles.xml" and tag == (OFFICENS, 'font-face-decls'): self.parse = False if self.parse == False: return self.level = self.level + 1 # Add any accumulated text content content = ''.join(self.data) if len(content.strip()) > 0: self.parent.addText(content, check_grammar=False) self.data = [] # Create the element attrdict = {} for (att,value) in list(attrs.items()): attrdict[att] = value try: e = Element(qname = tag, qattributes=attrdict, check_grammar=False) self.curr = e except AttributeError as v: print("Error: %s" % v) if tag == (OFFICENS, 'automatic-styles'): e = self.doc.automaticstyles elif tag == (OFFICENS, 'body'): e = self.doc.body elif tag == (OFFICENS, 'master-styles'): e = self.doc.masterstyles elif tag == (OFFICENS, 'meta'): e = self.doc.meta elif tag == (OFFICENS,'scripts'): e = self.doc.scripts elif tag == (OFFICENS,'settings'): e = self.doc.settings elif tag == (OFFICENS,'styles'): e = self.doc.styles elif self.doc._parsing == "styles.xml" and tag == (OFFICENS, 'font-face-decls'): e = self.doc.fontfacedecls elif hasattr(self,'parent'): self.parent.addElement(e, check_grammar=False) self.parent = e def endElementNS(self, tag, qname): if self.parse == False: return self.level = self.level - 1 str = ''.join(self.data) if len(str.strip()) > 0: self.curr.addText(str, check_grammar=False) self.data = [] self.curr = self.curr.parentNode self.parent = self.curr if tag in self.triggers: self.parse = False