本文整理汇总了Python中zoundry.base.zdom.dom.ZDom.load方法的典型用法代码示例。如果您正苦于以下问题:Python ZDom.load方法的具体用法?Python ZDom.load怎么用?Python ZDom.load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zoundry.base.zdom.dom.ZDom
的用法示例。
在下文中一共展示了ZDom.load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _importBlogPost
# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import load [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: _load
# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import load [as 别名]
def _load(self):
if not self.registryFile or not os.path.exists(self.registryFile):
return
mediaStorageDir = os.path.basename(self.registryFile)
dom = ZDom()
dom.load(self.registryFile)
# Legacy handling - old registry file format
for fileElem in dom.selectNodes(u"/registry/file"): #$NON-NLS-1$
fileName = fileElem.getText()
size = int(fileElem.getAttribute(u"size")) #$NON-NLS-1$
timestamp = ZSchemaDateTime(fileElem.getAttribute(u"timestamp")) #$NON-NLS-1$
url = fileElem.getAttribute(u"url") #$NON-NLS-1$
self.addFile(fileName, size, timestamp, url)
# New registry file format
for entryElem in dom.selectNodes(u"/registry/entry"): #$NON-NLS-1$
size = int(entryElem.getAttribute(u"size")) #$NON-NLS-1$
timestamp = ZSchemaDateTime(entryElem.getAttribute(u"timestamp")) #$NON-NLS-1$
relativeFileName = entryElem.selectSingleNodeText(u"file") #$NON-NLS-1$
fileName = resolveRelativePath(mediaStorageDir, relativeFileName)
url = entryElem.selectSingleNodeText(u"url") #$NON-NLS-1$
embedFragment = entryElem.selectSingleNode(u"embed/*") #$NON-NLS-1$
metaData = entryElem.selectSingleNode(u"metaData/*") #$NON-NLS-1$
uploadResponse = ZUploadResponse(url, embedFragment, metaData)
self.addFileEntry(fileName, size, timestamp, uploadResponse)
示例3: _importAccount
# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import load [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
示例4: _getJoeyUserConfigDom
# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import load [as 别名]
def _getJoeyUserConfigDom(self):
try:
configFile = os.path.join(self.pathToSourceProfile, u"joey-user-config.xml") #$NON-NLS-1$
dom = ZDom()
dom.load(configFile)
return dom
except:
return None
示例5: _getJoeyLocalFilesDom
# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import load [as 别名]
def _getJoeyLocalFilesDom(self):
try:
f = os.path.join(self.pathToSourceProfile, u"mediarep\\zlocalfiles.xml") #$NON-NLS-1$
dom = ZDom()
dom.load(f)
return dom
except:
return None
示例6: _loadProfilesDom
# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import load [as 别名]
def _loadProfilesDom(self):
domPath = self._getProfilesXmlPath()
dom = ZDom()
if not os.path.exists(domPath):
dom.loadXML(DEFAULT_PROFILES_XML)
else:
dom.load(domPath)
return dom
示例7: loadWordListXML
# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import load [as 别名]
def loadWordListXML(filePath):
u"""loadWordListXML(string) -> string []
Loads the wordlist.xml file at the given path and parses
it into a list of strings.""" #$NON-NLS-1$
dom = ZDom()
dom.load(filePath)
nssMap = { u"ns" : IZAppNamespaces.RAVEN_WORD_LIST_NAMESPACE } #$NON-NLS-1$
nodes = dom.selectNodes(u"/ns:word-list/ns:word", nssMap) #$NON-NLS-1$
return map(_getElementText, nodes)
示例8: loadStoreEntry
# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import load [as 别名]
def loadStoreEntry(entry, entryXmlPath):
u"""loadStoreEntry(ZResourceStoreEntry , string) -> ZResourceStoreEntry
""" #$NON-NLS-1$
try:
dom = ZDom()
dom.load(entryXmlPath)
return ZResourceStoreEntryDeserializer().deserialize(entry, dom)
except Exception, e:
raise e
示例9: loadBackgroundTask
# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import load [as 别名]
def loadBackgroundTask(taskXmlPath):
try:
dom = ZDom()
dom.load(taskXmlPath)
deserializer = getBackgroundTaskDeserializerFactory().getDeserializer(dom.documentElement.getNamespaceUri())
return deserializer.deserialize(dom)
except Exception, e:
raise ZAppFrameworkException(_extstr(u"backgroundtaskio.FailedToLoadTask") % taskXmlPath, e) #$NON-NLS-1$
示例10: _loadBundleStringsFromFile
# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import load [as 别名]
def _loadBundleStringsFromFile(self, fileName, stringMap):
nsMap = { u"zb" : u"http://www.zoundry.com/schemas/2006/06/zbundle.rng" } #$NON-NLS-1$ #$NON-NLS-2$
dom = ZDom()
dom.load(fileName)
stringElems = dom.selectNodes(u"/zb:string-bundle/zb:string", nsMap) #$NON-NLS-1$
for stringElem in stringElems:
key = stringElem.getAttribute(u"name") #$NON-NLS-1$
value = stringElem.getText()
stringMap[key] = value
示例11: loadCountryCodes
# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import load [as 别名]
def loadCountryCodes(xmlFilePath):
try:
dom = ZDom()
dom.load(xmlFilePath)
deserializer = getI18NDeserializerFactory().getDeserializer(dom.documentElement.getNamespaceUri())
return deserializer.deserialize(dom)
except Exception, e:
raise ZAppFrameworkException(_extstr(u"i18nserviceio.ErrorLoadingCountryCodes"), e) #$NON-NLS-1$
示例12: loadDictionariesXML
# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import load [as 别名]
def loadDictionariesXML(filePath):
u"""loadDictionariesXML(string) -> IZSpellCheckDictionaryLanguage []
Loads the dictionaries.xml file at the given path and parses
it into a list of IZSpellCheckDictionaryLanguage objects.""" # $NON-NLS-1$
dom = ZDom()
dom.load(filePath)
nssMap = {u"ns": IZAppNamespaces.RAVEN_DICTIONARIES_NAMESPACE} # $NON-NLS-1$
nodes = dom.selectNodes(u"/ns:dictionaries/ns:dictionary", nssMap) # $NON-NLS-1$
return map(_createSpellCheckDictionaryLanguage, nodes)
示例13: loadTemplate
# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import load [as 别名]
def loadTemplate(templateDir):
try:
templateXmlPath = os.path.join(templateDir, u"template.xml") #$NON-NLS-1$
dom = ZDom()
dom.load(templateXmlPath)
deserializer = getTemplateDeserializerFactory().getDeserializer(dom.documentElement.getNamespaceUri())
return deserializer.deserialize(templateDir, dom)
except Exception, e:
raise ZBlogAppException(u"Failed to load template: %s" % templateDir, e) #$NON-NLS-1$
示例14: loadAccount
# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import load [as 别名]
def loadAccount(accountDir):
try:
accountXmlPath = os.path.join(accountDir, u"account.xml") #$NON-NLS-1$
dom = ZDom()
dom.load(accountXmlPath)
deserializer = getAccountDeserializerFactory().getDeserializer(dom.documentElement.getNamespaceUri())
return deserializer.deserialize(accountDir, dom)
except Exception, e:
raise ZBlogAppException(_extstr(u"accountio.FailedToLoadAccount") % accountDir, e) #$NON-NLS-1$
示例15: importAccountBlogMediaStores
# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import load [as 别名]
def importAccountBlogMediaStores(self, accountXmlPathList):
for accountXmlPath in accountXmlPathList:
joeyAccountDom = ZDom()
joeyAccountDom.load(accountXmlPath)
for blogNode in joeyAccountDom.selectNodes(u"//blogs/blog[child::mediarep/text()='publisher']"): #$NON-NLS-1$
try:
blogId = blogNode.selectSingleNode(u"id").getText() #$NON-NLS-1$
regList = self._getRegistryEntries(blogId) #@UnusedVariable
# FIXME (PJ) create Raven metaweblog media site for blogId. Add regFiles to media store reg. Associate *raven* account with media store
except:
pass