本文整理汇总了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
示例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()
示例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)]
示例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))
示例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
示例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")
示例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())