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


Python dom.ZDom类代码示例

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


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

示例1: _importBlogPost

    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,代码行数:32,代码来源:zbwimporter.py

示例2: _doHandleError

 def _doHandleError(self, url, dndContext):
     ZShowInfoMessage(dndContext.getWindow(), _extstr(u"commonvideo.ErrorDiscoveringVideoEmbedInfoMsg"), _extstr(u"commonvideo.ErrorDiscoveringVideoEmbedInfoTitle")) #$NON-NLS-2$ #$NON-NLS-1$
     dom = ZDom()
     dom.loadXML(u"<a href='' />") #$NON-NLS-1$
     dom.documentElement.setAttribute(u"href", url) #$NON-NLS-1$
     dom.documentElement.setText(url)
     return dom.serialize()
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:7,代码来源:commonvideo.py

示例3: _importAccount

    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,代码行数:30,代码来源:zbwimporter.py

示例4: serialize

 def serialize(self, entry):
     dom = ZDom()
     dom.loadXML(u"<resource-entry  xmlns='%s' />" % self.namespace) #$NON-NLS-1$
     root = dom.documentElement
     root.setAttribute(u"id", entry.getId()) #$NON-NLS-1$
     self._serializeAttributes(entry,root)
     return dom
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:7,代码来源:resourcestoreio.py

示例5: createHtmlElement

def createHtmlElement(parentElement, elementName, attrMap = {}, elementText = None):
    u"""createHtmlElement(Node, string, map, string) -> Node
    Creates a element given element name, attribute map and optional element node text.
    If the parentElement node is None, then element is under new document (zdom).
     """ #$NON-NLS-1$
    element = None
    elementName = getNoneString(elementName)
    elementText = getNoneString(elementText)
    if not elementName:
        return None
    dom = None
    if parentElement:
        dom = parentElement.ownerDocument
    else:
        dom = ZDom()
        dom.loadXML(ELEMENT_TEMPLATE)
        parentElement = dom.documentElement
    try:
        element = dom.createElement(elementName)
        parentElement.appendChild(element)
        for (n,v) in attrMap.iteritems():
            if n and v:                
                element.setAttribute(n,v)
        if elementText:
            element.setText(elementText)
    except:
        pass    
    return element
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:28,代码来源:xhtmldocutil.py

示例6: _load

    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,代码行数:26,代码来源:mediastoragereg.py

示例7: _loadProfilesDom

 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,代码行数:8,代码来源:manager.py

示例8: _getJoeyLocalFilesDom

 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,代码行数:8,代码来源:zbwimporter.py

示例9: _getJoeyUserConfigDom

 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,代码行数:8,代码来源:zbwimporter.py

示例10: loadStoreEntry

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,代码行数:9,代码来源:resourcestoreio.py

示例11: loadBackgroundTask

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,代码行数:9,代码来源:backgroundtaskio.py

示例12: _loadBundleStringsFromFile

 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,代码行数:9,代码来源:translationmodel.py

示例13: loadDictionariesXML

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,代码行数:9,代码来源:dictionariesio.py

示例14: loadCountryCodes

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,代码行数:9,代码来源:i18nserviceio.py

示例15: loadWordListXML

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,代码行数:9,代码来源:wordlistio.py


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