当前位置: 首页>>代码示例>>Python>>正文


Python odf_parser.OdfParser类代码示例

本文整理汇总了Python中appy.pod.odf_parser.OdfParser的典型用法代码示例。如果您正苦于以下问题:Python OdfParser类的具体用法?Python OdfParser怎么用?Python OdfParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OdfParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, env, caller):
     OdfParser.__init__(self, env, caller)
     self.res = ""
     self.inAnnotation = False  # Are we parsing an annotation ?
     self.textEncountered = False  # Within an annotation, have we already
     # met a text ?
     self.ignore = False  # Must we avoid dumping the current tag/content
开发者ID:PeterEymann,项目名称:appypod,代码行数:7,代码来源:Tester.py

示例2: startElement

 def startElement(self, elem, attrs):
     e = OdfParser.startElement(self, elem, attrs)
     ns = e.onStartElement()
     officeNs = ns[e.NS_OFFICE]
     textNs = ns[e.NS_TEXT]
     if elem in e.ignorableElements:
         e.state = e.IGNORING
     elif elem == ('%s:annotation' % officeNs):
         e.state = e.READING_STATEMENT
     elif (elem == ('%s:change-start' % textNs)) or \
          (elem == ('%s:conditional-text' % textNs)):
         e.state = e.READING_EXPRESSION
         e.exprHasStyle = False
     else:
         if e.state == e.IGNORING:
             pass
         elif e.state == e.READING_CONTENT:
             if elem in e.impactableElements:
                 if e.mode == e.ADD_IN_SUBBUFFER:
                     e.addSubBuffer()
                 e.currentBuffer.addElement(e.currentElem.name)
             e.currentBuffer.dumpStartElement(elem, attrs)
         elif e.state == e.READING_STATEMENT:
             pass
         elif e.state == e.READING_EXPRESSION:
             if (elem == ('%s:span' % textNs)) and \
                not e.currentContent.strip():
                 e.currentBuffer.dumpStartElement(elem, attrs)
                 e.exprHasStyle = True
     e.manageInserts()
开发者ID:a-iv,项目名称:appy,代码行数:30,代码来源:pod_parser.py

示例3: startElement

 def startElement(self, elem, attrs):
     e = OdfParser.startElement(self, elem, attrs)
     self.styleTag = '%s:style' % e.ns(e.NS_STYLE)
     if elem == self.styleTag:
         e.state = PARSING_STYLE
         nameAttr = '%s:name' % e.ns(e.NS_STYLE)
         familyAttr = '%s:family' % e.ns(e.NS_STYLE)
         classAttr = '%s:class' % e.ns(e.NS_STYLE)
         displayNameAttr = '%s:display-name' % e.ns(e.NS_STYLE)
         # Create the style
         style = Style(name=attrs[nameAttr], family=attrs[familyAttr])
         if classAttr in attrs:
             style.styleClass = attrs[classAttr]
         if displayNameAttr in attrs:
             style.displayName = attrs[displayNameAttr]
         # Record this style in the environment
         e.styles[style.name] = style
         e.currentStyle = style
         levelKey = '%s:default-outline-level' % e.ns(e.NS_STYLE)
         if levelKey in attrs and attrs[levelKey].strip():
             style.outlineLevel = int(attrs[levelKey])
     else:
         if e.state == PARSING_STYLE:
             # I am parsing tags within the style.
             if elem == ('%s:text-properties' % e.ns(e.NS_STYLE)):
                 fontSizeKey = '%s:font-size' % e.ns(e.NS_FO)
                 if fontSizeKey in attrs:
                     e.currentStyle.setFontSize(attrs[fontSizeKey])
开发者ID:PeterEymann,项目名称:appypod,代码行数:28,代码来源:styles_manager.py

示例4: endElement

 def endElement(self, elem):
     e = OdfParser.endElement(self, elem)
     if elem == "%s:annotation" % e.ns(e.NS_OFFICE):
         self.inAnnotation = False
         self.ignore = False
     if not self.ignore:
         self.res += "</%s>" % elem
开发者ID:PeterEymann,项目名称:appypod,代码行数:7,代码来源:Tester.py

示例5: characters

 def characters(self, content):
     e = OdfParser.characters(self, content)
     if not self.ignore:
         for c in content:
             if XML_SPECIAL_CHARS.has_key(c):
                 self.res += XML_SPECIAL_CHARS[c]
             else:
                 self.res += c
开发者ID:vampolo,项目名称:cacerp,代码行数:8,代码来源:Tester.py

示例6: startElement

 def startElement(self, elem, attrs):
     e = OdfParser.startElement(self, elem, attrs)
     ns = e.onStartElement()
     officeNs = ns[e.NS_OFFICE]
     textNs = ns[e.NS_TEXT]
     tableNs = ns[e.NS_TABLE]
     if elem in e.ignorableElems:
         e.state = e.IGNORING
     elif elem == e.tags['annotation']:
         # Be it in an ODT or ODS template, an annotation is considered to
         # contain a POD statement.
         e.state = e.READING_STATEMENT
     elif elem in e.exprStartElems:
         # Any track-changed text or being in a conditional or input field is
         # considered to be a POD expression.
         e.state = e.READING_EXPRESSION
         e.exprHasStyle = False
     elif (elem == e.tags['table-cell']) and \
          attrs.has_key(e.tags['formula']) and \
          attrs.has_key(e.tags['value-type']) and \
          (attrs[e.tags['value-type']] == 'string') and \
          attrs[e.tags['formula']].startswith('of:="'):
         # In an ODS template, any cell containing a formula of type "string"
         # and whose content is expressed as a string between double quotes
         # (="...") is considered to contain a POD expression. But here it
         # is a special case: we need to dump the cell; the expression is not
         # directly contained within this cell; the expression will be
         # contained in the next inner paragraph. So we must here dump the
         # cell, but without some attributes, because the "formula" will be
         # converted to the result of evaluating the POD expression.
         if e.mode == e.ADD_IN_SUBBUFFER:
             e.addSubBuffer()
         e.currentBuffer.addElement(e.currentElem.name)
         hook = e.currentBuffer.dumpStartElement(elem, attrs,
                  ignoreAttrs=(e.tags['formula'], e.tags['string-value'],
                               e.tags['value-type']),
                  hook=True)
         # We already have the POD expression: remember it on the env.
         e.currentOdsExpression = attrs[e.tags['string-value']]
         e.currentOdsHook = hook
     else:
         if e.state == e.IGNORING:
             pass
         elif e.state == e.READING_CONTENT:
             if elem in e.impactableElems:
                 if e.mode == e.ADD_IN_SUBBUFFER:
                     e.addSubBuffer()
                 e.currentBuffer.addElement(e.currentElem.name)
             e.currentBuffer.dumpStartElement(elem, attrs)
         elif e.state == e.READING_STATEMENT:
             pass
         elif e.state == e.READING_EXPRESSION:
             if (elem == (e.tags['span'])) and not e.currentContent.strip():
                 e.currentBuffer.dumpStartElement(elem, attrs)
                 e.exprHasStyle = True
     e.manageInserts()
开发者ID:tonibagur,项目名称:appy,代码行数:56,代码来源:pod_parser.py

示例7: endElement

 def endElement(self, elem):
     e = OdfParser.endElement(self, elem)
     if elem == e.tags['style']:
         e.state = READING
         e.currentStyle = None
     elif elem == e.tags['page-layout']:
         e.state = READING
         e.currentPageLayout = None
     elif elem == e.tags['master-styles']:
         e.state = READING
开发者ID:tonibagur,项目名称:appy,代码行数:10,代码来源:styles_manager.py

示例8: characters

 def characters(self, content):
     e = OdfParser.characters(self, content)
     if e.state == e.IGNORING:
         pass
     elif e.state == e.READING_CONTENT:
         e.currentBuffer.dumpContent(content)
     elif e.state == e.READING_STATEMENT:
         if e.currentElem.elem.startswith(e.namespaces[e.NS_TEXT]):
             e.currentContent += content
     elif e.state == e.READING_EXPRESSION:
         e.currentContent += content
开发者ID:a-iv,项目名称:appy,代码行数:11,代码来源:pod_parser.py

示例9: characters

 def characters(self, content):
     e = OdfParser.characters(self, content)
     if e.state == e.IGNORING:
         pass
     elif e.state == e.READING_CONTENT:
         if e.currentOdsExpression:
             # Do not write content if we have encountered an ODS expression:
             # we will replace this content with the expression's result.
             pass
         else:
             e.currentBuffer.dumpContent(content)
     elif e.state == e.READING_STATEMENT:
         if e.currentElem.elem.startswith(e.namespaces[e.NS_TEXT]):
             e.currentContent += content
     elif e.state == e.READING_EXPRESSION:
         e.currentContent += content
开发者ID:akarambir,项目名称:django-sis,代码行数:16,代码来源:pod_parser.py

示例10: startElement

    def startElement(self, elem, attrs):
        e = OdfParser.startElement(self, elem, attrs)
        ns = e.onStartElement()
        if elem == e.tags['style']:
            e.state = PARSING_STYLE
            # Create the style
            style = Style(name=attrs[e.tags['name']],
                          family=attrs[e.tags['family']])
            classAttr = e.tags['class']
            if attrs.has_key(classAttr): style.styleClass = attrs[classAttr]
            dnAttr = e.tags['display-name']
            if attrs.has_key(dnAttr): style.displayName = attrs[dnAttr]
            dolAttr = e.tags['default-outline-level']
            if attrs.has_key(dolAttr) and attrs[dolAttr].strip():
                style.outlineLevel = int(attrs[dolAttr])
            # Record this style in the environment
            e.styles[style.name] = style
            e.currentStyle = style

        elif elem == e.tags['page-layout']:
            e.state = PARSING_PAGE_LAYOUT
            pageLayout = PageLayout(attrs[e.tags['name']])
            # Record this page layout in the environment
            e.pageLayouts[pageLayout.name] = pageLayout
            e.currentPageLayout = pageLayout

        elif elem == e.tags['master-styles']:
            e.state = PARSING_MASTER_STYLES

        elif e.state == PARSING_STYLE:
            # Find properties within this style definition
            if elem == e.tags['text-properties']:
                fontSizeAttr = e.tags['font-size']
                if attrs.has_key(fontSizeAttr):
                    e.currentStyle.setFontSize(attrs[fontSizeAttr])

        elif e.state == PARSING_PAGE_LAYOUT:
            # Find properties within this page layout definition
            if elem == e.tags['page-layout-properties']:
                e.currentPageLayout.setProperties(e, attrs)

        elif e.state == PARSING_MASTER_STYLES:
            # I am parsing section "master-styles"
            if elem == e.tags['master-page']:
                plnAttr = e.tags['page-layout-name']
                if attrs.has_key(plnAttr):
                    e.masterLayoutName = attrs[plnAttr]
开发者ID:tonibagur,项目名称:appy,代码行数:47,代码来源:styles_manager.py

示例11: startElement

 def startElement(self, elem, attrs):
     e = OdfParser.startElement(self, elem, attrs)
     # Do we enter into an annotation ?
     if elem == "%s:annotation" % e.ns(e.NS_OFFICE):
         self.inAnnotation = True
         self.textEncountered = False
     elif elem == "%s:p" % e.ns(e.NS_TEXT):
         if self.inAnnotation:
             if not self.textEncountered:
                 self.textEncountered = True
             else:
                 self.ignore = True
     if not self.ignore:
         self.res += "<%s" % elem
         for attrName, attrValue in list(attrs.items()):
             self.res += ' %s="%s"' % (attrName, attrValue)
         self.res += ">"
开发者ID:PeterEymann,项目名称:appypod,代码行数:17,代码来源:Tester.py

示例12: endElement

 def endElement(self, elem):
     e = OdfParser.endElement(self, elem)
     if elem == self.styleTag:
         e.state = READING
         e.currentStyle = None
开发者ID:PeterEymann,项目名称:appypod,代码行数:5,代码来源:styles_manager.py

示例13: endDocument

 def endDocument(self):
     e = OdfParser.endDocument(self)
     self.caller.styles = e.styles
开发者ID:PeterEymann,项目名称:appypod,代码行数:3,代码来源:styles_manager.py

示例14: __init__

 def __init__(self, env, caller):
     OdfParser.__init__(self, env, caller)
     env.raiseOnError = caller.raiseOnError
开发者ID:tonibagur,项目名称:appy,代码行数:3,代码来源:pod_parser.py

示例15: __init__

 def __init__(self, env, caller):
     OdfParser.__init__(self, env, caller)
     self.styleTag = None
开发者ID:PeterEymann,项目名称:appypod,代码行数:3,代码来源:styles_manager.py


注:本文中的appy.pod.odf_parser.OdfParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。