本文整理汇总了Python中zoundry.base.zdom.dom.ZDom.importNode方法的典型用法代码示例。如果您正苦于以下问题:Python ZDom.importNode方法的具体用法?Python ZDom.importNode怎么用?Python ZDom.importNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zoundry.base.zdom.dom.ZDom
的用法示例。
在下文中一共展示了ZDom.importNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _save
# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import importNode [as 别名]
def _save(self):
if not self.registryFile:
return
mediaStorageDir = os.path.basename(self.registryFile)
dom = ZDom()
dom.loadXML(u"<registry/>") #$NON-NLS-1$
registryElem = dom.documentElement
for fileName in self.fileMap:
(size, timestamp, uploadResponse) = self.fileMap[fileName]
relativeFileName = makeRelativePath(mediaStorageDir, fileName)
url = uploadResponse.getUrl()
embedFragment = uploadResponse.getEmbedFragment()
metaData = uploadResponse.getMetaData()
entryElem = dom.createElement(u"entry") #$NON-NLS-1$
entryElem.setAttribute(u"size", unicode(size)) #$NON-NLS-1$
entryElem.setAttribute(u"timestamp", unicode(timestamp)) #$NON-NLS-1$
fileElem = dom.createElement(u"file") #$NON-NLS-1$
urlElem = dom.createElement(u"url") #$NON-NLS-1$
embedElem = dom.createElement(u"embed") #$NON-NLS-1$
metaDataElem = dom.createElement(u"metaData") #$NON-NLS-1$
# When in portable mode, save the file paths as relative (which will
# only happen when the image is on the same drive as the app).
if isPortableEnabled():
fileElem.setText(relativeFileName)
else:
fileElem.setText(fileName)
entryElem.appendChild(fileElem)
if url:
urlElem.setText(unicode(url))
entryElem.appendChild(urlElem)
if embedFragment is not None:
embedElem.appendChild(dom.importNode(embedFragment, True))
entryElem.appendChild(embedElem)
if metaData is not None:
metaDataElem.appendChild(dom.importNode(metaData, True))
entryElem.appendChild(metaDataElem)
registryElem.appendChild(entryElem)
dom.save(self.registryFile, True)