當前位置: 首頁>>代碼示例>>Python>>正文


Python ZDom.selectSingleNode方法代碼示例

本文整理匯總了Python中zoundry.base.zdom.dom.ZDom.selectSingleNode方法的典型用法代碼示例。如果您正苦於以下問題:Python ZDom.selectSingleNode方法的具體用法?Python ZDom.selectSingleNode怎麽用?Python ZDom.selectSingleNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在zoundry.base.zdom.dom.ZDom的用法示例。


在下文中一共展示了ZDom.selectSingleNode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: readDnDSource

# 需要導入模塊: from zoundry.base.zdom.dom import ZDom [as 別名]
# 或者: from zoundry.base.zdom.dom.ZDom import selectSingleNode [as 別名]
    def readDnDSource(self, stgMedium):
        fmtstring = unicode(len(stgMedium.data)) + u"s" #$NON-NLS-1$
        dataTuple = unpack(fmtstring, stgMedium.data)
        cfhtml = dataTuple[0]
        html = self._decodeCfHtml(cfhtml)
        htmlDom = ZDom()
        rootNode = None
        try:
            htmlDom.loadHTML(html)
            rootNode = htmlDom.selectSingleNode(u"/*") #$NON-NLS-1$
        except:
            # Probably an encoding problem of some sort - just
            # return None (we are going to let IE handle it anyway)
            pass

        return ZHtmlDnDSource(rootNode)
開發者ID:Tidosho,項目名稱:zoundryraven,代碼行數:18,代碼來源:dndreaders.py

示例2: importPersonalDictionary

# 需要導入模塊: from zoundry.base.zdom.dom import ZDom [as 別名]
# 或者: from zoundry.base.zdom.dom.ZDom import selectSingleNode [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

示例3: _loadDefaultLoggerNode

# 需要導入模塊: from zoundry.base.zdom.dom import ZDom [as 別名]
# 或者: from zoundry.base.zdom.dom.ZDom import selectSingleNode [as 別名]
 def _loadDefaultLoggerNode(self):
     dom = ZDom()
     dom.loadXML(DEFAULT_LOG_XML)
     return dom.selectSingleNode(u"/") #$NON-NLS-1$
開發者ID:Tidosho,項目名稱:zoundryraven,代碼行數:6,代碼來源:logger.py

示例4: _getAddProductPostDataForUrl

# 需要導入模塊: from zoundry.base.zdom.dom import ZDom [as 別名]
# 或者: from zoundry.base.zdom.dom.ZDom import selectSingleNode [as 別名]
 def _getAddProductPostDataForUrl(self, productUrl, zoundryServiceId):
     dom = ZDom(ADD_PRODUCT_REQUEST)
     dom.selectSingleNode(u"/Request/Authorization/Username").setText(zoundryServiceId) #$NON-NLS-1$
     dom.selectSingleNode(u"/Request/AddProducts/Product/Url").setText(productUrl) #$NON-NLS-1$
     return dom.serialize(True)
開發者ID:Tidosho,項目名稱:zoundryraven,代碼行數:7,代碼來源:productsvcimpl.py


注:本文中的zoundry.base.zdom.dom.ZDom.selectSingleNode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。