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


Python XML.parseString方法代码示例

本文整理汇总了Python中cia.LibCIA.XML.parseString方法的典型用法代码示例。如果您正苦于以下问题:Python XML.parseString方法的具体用法?Python XML.parseString怎么用?Python XML.parseString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cia.LibCIA.XML的用法示例。


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

示例1: param_noColor

# 需要导入模块: from cia.LibCIA import XML [as 别名]
# 或者: from cia.LibCIA.XML import parseString [as 别名]
 def param_noColor(self, tag):
     """The <noColor> parameter disables colors.
        This is equivalent to a <format> parameter with CommitFormatter's
        default component tree.
        """
     self.componentTree = XML.parseString(CommitFormatter.defaultComponentTree
                                          ).documentElement
开发者ID:Justasic,项目名称:cia-vc,代码行数:9,代码来源:Commit.py

示例2: syncFromServer

# 需要导入模块: from cia.LibCIA import XML [as 别名]
# 或者: from cia.LibCIA.XML import parseString [as 别名]
    def syncFromServer(self):
        """Update this Bot from the RPC server, if necessary.
           Right now the only task this performs is to store the
           server's ruleset if filterMode is 'unknown'.
           """
        if self.filter_mode != FILTER.UNKNOWN:
            return

        ruleset = self._loadRuleset()
        if not ruleset:
            # If there's no ruleset, mark the bot as inactive.
            self.filter_mode = FILTER.INACTIVE
            self.save()
            return

        # Parse the ruleset using LibCIA's XML library
        from cia.LibCIA import XML
        dom = XML.parseString(ruleset)

        # XXX: We should try to reduce the ruleset to one of
        #      the other FILTER.* modes if possible. For now,
        #      we'll always import existing rulesets as
        #      FILTER.CUSTOM.

        # Flatten the contents of the <ruleset> element, clean up
        # the resulting text, and save that as a custom filter.

        text = ''.join([n.toxml() for n in dom.documentElement.childNodes])
        self.filter_mode = FILTER.CUSTOM
        self.custom_ruleset = clean_up_text(text)
        self.save()
开发者ID:Justasic,项目名称:cia-vc,代码行数:33,代码来源:models.py

示例3: caps_store

# 需要导入模块: from cia.LibCIA import XML [as 别名]
# 或者: from cia.LibCIA.XML import parseString [as 别名]
 def caps_store(self, path, xml):
     """Generate a list of acceptable capabilities to grant access to 'store'.
        In addition to the usual ones, allow ('ruleset.uri', x) where x is the
        ruleset's URI.
        """
     if (xml.startswith('[')):
         uri = xml.split('\n')[0][2:]
     else:
         uri = XML.parseString(xml).documentElement.getAttributeNS(None, 'uri')
     return self.makeDefaultCaps(path) + [('ruleset.uri', uri)]
开发者ID:Justasic,项目名称:cia-vc,代码行数:12,代码来源:Ruleset.py

示例4: format

# 需要导入模块: from cia.LibCIA import XML [as 别名]
# 或者: from cia.LibCIA.XML import parseString [as 别名]
    def format(self, args):
        """The formatter entry point. This just finds the current component
           tree and invokes walkComponents and joinComponents on it.
           """
        # Parse the default component tree, caching it per-class
        if self.__class__._defaultTreeOwner is not self.__class__.defaultComponentTree:
            self.__class__._defaultTreeOwner = self.__class__.defaultComponentTree
            self.__class__._cachedDefaultTree = XML.parseString(self.__class__.defaultComponentTree).documentElement

        # This will use the default component tree if it hasn't been overridden in this instance
        tree = self.componentTree or self.__class__._cachedDefaultTree
        return self.joinComponents(self.walkComponents(tree.childNodes, args))
开发者ID:Justasic,项目名称:cia-vc,代码行数:14,代码来源:Message.py

示例5: getSvnRevision

# 需要导入模块: from cia.LibCIA import XML [as 别名]
# 或者: from cia.LibCIA.XML import parseString [as 别名]
 def getSvnRevision(self):
     """Return the current Subversion repository revision, or None
        if we're not in an svn working copy or it can't be parsed.
        """
     try:
         entries = XML.parseString(open(".svn/entries").read()).documentElement
         highestRev = 0
         for tag in XML.getChildElements(entries):
             if tag.nodeName == 'entry':
                 rev = tag.getAttributeNS(None, 'committed-rev')
                 if rev and rev > highestRev:
                     highestRev = rev
         return highestRev
     except:
         return None
开发者ID:Justasic,项目名称:cia-vc,代码行数:17,代码来源:Info.py

示例6: dbStore

# 需要导入模块: from cia.LibCIA import XML [as 别名]
# 或者: from cia.LibCIA.XML import parseString [as 别名]
    def dbStore(self, ruleset=None):
        """Write all rulesets to disk in one big XML file"""
        doc = XML.parseString("<rulesets>\n"
                              "<!--\n"
                              "This is a ruleset storage for CIA. It tells the CIA server\n"
                              "how to deliver messages. Don't edit it by hand while the server\n"
                              "is running, use tools/ruleset_editor.py\n"
                              "-->\n"
                              "\n"
                              "</rulesets>")
        root = doc.documentElement
        for ruleset in self.flatten():
            root.appendChild(XML.Domlette.ConvertDocument(ruleset.xml).documentElement)
            root.appendChild(doc.createTextNode("\n\n"))

        f = open(self.path, "w")
        XML.Domlette.Print(doc, f)
        f.write("\n")
开发者ID:Justasic,项目名称:cia-vc,代码行数:20,代码来源:Ruleset.py

示例7: command_DeliverXML

# 需要导入模块: from cia.LibCIA import XML [as 别名]
# 或者: from cia.LibCIA.XML import parseString [as 别名]
 def command_DeliverXML(self):
     """Deliver a message already formatted in XML"""
     # Note that parseString will convert UTF8 to Unicode for us.
     return XML.parseString(self.message.get_payload())
开发者ID:Justasic,项目名称:cia-vc,代码行数:6,代码来源:IncomingMail.py


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