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


Python ZDom.load方法代码示例

本文整理汇总了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
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:34,代码来源:zbwimporter.py

示例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)
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:28,代码来源:mediastoragereg.py

示例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
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:32,代码来源:zbwimporter.py

示例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
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:10,代码来源:zbwimporter.py

示例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
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:10,代码来源:zbwimporter.py

示例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
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:10,代码来源:manager.py

示例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)
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:11,代码来源:wordlistio.py

示例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
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:11,代码来源:resourcestoreio.py

示例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$
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:11,代码来源:backgroundtaskio.py

示例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
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:11,代码来源:translationmodel.py

示例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$
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:11,代码来源:i18nserviceio.py

示例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)
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:11,代码来源:dictionariesio.py

示例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$
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:12,代码来源:templateio.py

示例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$
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:12,代码来源:accountio.py

示例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
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:13,代码来源:zbwimporter.py


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