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


Python ZDom.selectNodes方法代码示例

本文整理汇总了Python中zoundry.base.zdom.dom.ZDom.selectNodes方法的典型用法代码示例。如果您正苦于以下问题:Python ZDom.selectNodes方法的具体用法?Python ZDom.selectNodes怎么用?Python ZDom.selectNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在zoundry.base.zdom.dom.ZDom的用法示例。


在下文中一共展示了ZDom.selectNodes方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _load

# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import selectNodes [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

示例2: loadWordListXML

# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import selectNodes [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

示例3: loadDictionariesXML

# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import selectNodes [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

示例4: _loadBundleStringsFromFile

# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import selectNodes [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

示例5: importAccountBlogMediaStores

# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import selectNodes [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

示例6: _loadMerchantRegistry

# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import selectNodes [as 别名]
 def _loadMerchantRegistry(self):
     resourceReg = self.applicationModel.getResourceRegistry()
     merchantsXMLPath = resourceReg.getResourcePath(u"zservice/merchants.xml") #$NON-NLS-1$
     dom = ZDom()
     dom.load(merchantsXMLPath)
     nodeList = dom.selectNodes(u"//Merchants/Merchant") #$NON-NLS-1$
     if not nodeList:
         return
     for node in nodeList:
         merchant = self._createMerchant(node)
         if merchant:
             self.merchantRegistry.add(merchant)
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:14,代码来源:productsvcimpl.py

示例7: _loadBundle

# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import selectNodes [as 别名]
    def _loadBundle(self, bundleFilename):
        # Load the file and read in all its string mappings.
        dom = ZDom()
        dom.load(bundleFilename)
        dom.setNamespaceMap(SB_NSS_MAP)

        nl = dom.selectNodes(u"/sb:string-bundle/sb:string") #$NON-NLS-1$
        for n in nl:
            name = n.getAttribute(u"name") #$NON-NLS-1$
            val = n.getText()
            val = val.replace(u"\\n", u"\n") #$NON-NLS-2$ #$NON-NLS-1$
            val = val.replace(u"\\t", u"\t") #$NON-NLS-2$ #$NON-NLS-1$
            self.bundleMap[name] = val
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:15,代码来源:i18n.py

示例8: _loadMimeTypes

# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import selectNodes [as 别名]
 def _loadMimeTypes(self, applicationModel):
     rval = {}
     
     mimeTypeFile = applicationModel.getResourceRegistry().getResourcePath(u"mimetypes.xml") #$NON-NLS-1$
     mimeTypeDom = ZDom()
     mimeTypeDom.load(mimeTypeFile)
     mimeTypeDom.setNamespaceMap({ u"mt" : IZAppNamespaces.RAVEN_MIMETYPES_NAMESPACE }) #$NON-NLS-1$
     
     mimeTypeNodes = mimeTypeDom.selectNodes(u"/mt:mime-types/mt:mime-type") #$NON-NLS-1$
     for mimeTypeNode in mimeTypeNodes:
         type = mimeTypeNode.selectSingleNodeText(u"mt:type") #$NON-NLS-1$
         ext = mimeTypeNode.selectSingleNodeText(u"mt:extension") #$NON-NLS-1$
         rval[ext] = ZMimeType(type, ext)
         
     return rval
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:17,代码来源:mimetypesimpl.py

示例9: importPersonalDictionary

# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import selectNodes [as 别名]
    def importPersonalDictionary(self):
        joeyConfigDom = self._getJoeyUserConfigDom()
        if not joeyConfigDom:
            return
        try:
            node = joeyConfigDom.selectSingleNode(u"/joey/user-config/spell-check/language") #$NON-NLS-1$
            if not node:
                return
            spellcheckLang = getNoneString( node.getText())
            if not spellcheckLang:
                return

            # FIXME (EPW) we could support other languages...
            if not spellcheckLang == u"en_US": #$NON-NLS-1$
                return

            # 1) read all words from ZBW personal-dictionary.xml file
            # 2) create new spellchecker.xml DOM
            # 3) save new Raven spellchecker file to 'PROFILE\LANG\spellchecker.xml'

            joeyDictFile = os.path.join(self.pathToJoeyProfile, u"spelling/personal-dictionary.xml") #$NON-NLS-1$
            dom = ZDom()
            dom.load(joeyDictFile)
            dom.setNamespaceMap(ZBW_PERSONAL_DICTIONARY_NSS_MAP)
            wordNodeList = dom.selectNodes(u"/pd:personal-dictionary/pd:word") #$NON-NLS-1$
            
            newDom = ZDom()
            newDom.loadXML(ZBlogWriterDictionaryImporter.SPELLCHECK_TEMPLATE)
            newDom.setNamespaceMap(RAVEN_SPELLCHECK_NSS_MAP)
            personalDictElem = newDom.selectSingleNode(u"/spl:spellchecker/spl:personal-dictionary") #$NON-NLS-1$
            
            for wordNode in wordNodeList:
                word = wordNode.getText()
                newWordElem = newDom.createElement(u"word", IZBlogAppNamespaces.RAVEN_SPELLCHECKER_NAMESPACE) #$NON-NLS-1$
                newWordElem.setText(word)
                personalDictElem.appendChild(newWordElem)
            
            outputDir = os.path.join(self.pathToRavenProfile, u"spellcheck/en_US") #$NON-NLS-1$
            os.makedirs(outputDir)
            outputFile = os.path.join(outputDir, u"spellchecker.xml") #$NON-NLS-1$
            newDom.save(outputFile, True)
        except ZException, ze:
            # FIXME (EPW) need to report errors in some way
            ze.printStackTrace()
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:46,代码来源:zbwimporter.py

示例10: _getAccountDirList

# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import selectNodes [as 别名]
 def _getAccountDirList(self):
     accountDirPath = os.path.join(self.pathToJoeyProfile, u"accounts") #$NON-NLS-1$
     fullDirNames = []
     try:
         # get the account.xml ("table of contents") file into a dom
         accountsTocXmlFileName = os.path.join(accountDirPath, self._getAccountTocXmlFilename() ) #$NON-NLS-1$
         if not os.path.exists(accountsTocXmlFileName):
             return fullDirNames
         tocDom = ZDom()
         tocDom.load(accountsTocXmlFileName)
         accIdNodes = tocDom.selectNodes(u"/blog-accounts/blog-account/@id") #$NON-NLS-1$
         for accIdNode in accIdNodes:
             accId = accIdNode.getText()
             fullPath = os.path.join(accountDirPath, accId)
             if os.path.isdir(fullPath):
                 accountXmlFileName = os.path.join(fullPath, u"account.xml") #$NON-NLS-1$
                 if os.path.isfile(accountXmlFileName):
                     fullDirNames.append( (fullPath, accountXmlFileName) )
     except Exception, e:
         ze = ZException(e)
         ze.printStackTrace()
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:23,代码来源:zbwimporter.py


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