home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- from xml.sax import make_parser, handler
- from xml.sax.xmlreader import InputSource
- import xml.sax.saxutils as xml
- from element import Element
- from namespaces import OFFICENS
- from cStringIO import StringIO
-
- class LoadParser(handler.ContentHandler):
- 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 None
- 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 None
- self.level = self.level + 1
- content = ''.join(self.data).strip()
- if len(content) > 0:
- self.parent.addText(content, check_grammar = False)
- self.data = []
-
- attrdict = { }
- for att, value in attrs.items():
- attrdict[att] = value
-
-
- try:
- e = Element(qname = tag, qattributes = attrdict, check_grammar = False)
- self.curr = e
- except AttributeError:
- v = None
- 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 None
- 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
-
-
-
-