本文整理汇总了Python中zoundry.base.zdom.dom.ZDom.transformToXML方法的典型用法代码示例。如果您正苦于以下问题:Python ZDom.transformToXML方法的具体用法?Python ZDom.transformToXML怎么用?Python ZDom.transformToXML使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zoundry.base.zdom.dom.ZDom
的用法示例。
在下文中一共展示了ZDom.transformToXML方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _importBlogPost
# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import transformToXML [as 别名]
def _importBlogPost(self, jbeXmlFileName):
ravenXmlFileName = self._getRavenXmlFileName(jbeXmlFileName)
jbeHtmlFileName = self._getJbeHtmlFileName(jbeXmlFileName)
dom = ZDom()
dom.load(jbeXmlFileName)
newDom = dom.transformToXML(self.dataTransformFilename)
self._attachContent(newDom, jbeHtmlFileName)
removeNodeList = []
blogNodeList = []
published = False
for blogNode in newDom.selectNodes(u"/zns:entry/zns:blogs/zns:blog"): #$NON-NLS-1$
# since there is atleast one blog associated with the entry, assume the post
# is published
published = True
ravenAccountId = blogNode.getAttribute(u"account-id") #$NON-NLS-1$
joeyBlogId = blogNode.getAttribute(u"blog-id") #$NON-NLS-1$
qid = self._convertBlogId(ravenAccountId, joeyBlogId)
if self._hasBlog( qid.getId() ):
blogNodeList.append(blogNode)
self._convertBlogPostBlogInfo(ravenAccountId, qid.getId(), qid.getServerId(), blogNode)
else:
removeNodeList.append(blogNode)
# remove orphan blog infos
for blogNode in removeNodeList:
blogNode.parentNode.removeChild(blogNode)
# save only if there were any blogs associated with the entry or if the post is a draft (published = false)
if not published or (blogNodeList and len(blogNodeList) > 0):
newDom.save(ravenXmlFileName, True)
del dom
del newDom
示例2: _importAccount
# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import transformToXML [as 别名]
def _importAccount(self, joeyAccountDirName, accountXmlFileName):
ravenAccountDirName = self._getRavenAccountDirName(joeyAccountDirName)
ravenAccountXmlName = os.path.join(ravenAccountDirName, u"account.xml") #$NON-NLS-1$
os.makedirs(ravenAccountDirName)
# Copy over any icons that have been downloaded (or any other resource).
fileutil.copyFiles(joeyAccountDirName, ravenAccountDirName)
dom = ZDom()
dom.load(accountXmlFileName)
newDom = dom.transformToXML(self.accountTransformFilename)
newDom.setNamespaceMap(ACCOUNT_NSS_MAP)
# Encrypt the account password.
passwordNode = newDom.selectSingleNode(u"/zns:account/zns:attributes/zns:attribute[@name = 'password']") #$NON-NLS-1$
if passwordNode:
password = crypt.encryptPlainText(passwordNode.getText(), PASSWORD_ENCRYPTION_KEY)
passwordNode.setText(password)
# convert host, port & path combo to a single url attribute; also determine the raven publisher site/type.
self._convertApiInfo(newDom)
# account id
accId = newDom.documentElement.getAttribute(u"account-id") #$NON-NLS-1$
self.validAccounts[accId] = True
# convert blog and id format to raven format
blogNodeList = newDom.selectNodes(u"/zns:account/zns:blogs/zns:blog") #$NON-NLS-1$
for blogNode in blogNodeList:
self._convertAccBlogInfo(accId, blogNode)
# Save to disk.
newDom.save(ravenAccountXmlName, True)
del dom
del newDom