Exemple #1
0
    def _getAtom10(self, prefix=u"atom:"):  #$NON-NLS-1$
        # find service.post and service.feed links
        attrMap = {}
        relTypes = ZAtomRelTypes()
        #TODO: find uploadLink and categoriesLink.
        for node in self.getDom().selectNodes(u"/%sfeed/%slink" % (prefix, prefix)): #$NON-NLS-1$
            rel = node.getAttribute(u"rel") #$NON-NLS-1$
            type = node.getAttribute(u"type") #$NON-NLS-1$
            if relTypes.isFeedLink(rel, type):
                attrMap[ZAtomBlog.FEED_LINK] = node.getAttribute(u"href") #$NON-NLS-1$
            elif relTypes.isPostLink(rel,type):
                attrMap[ZAtomBlog.POST_LINK] = node.getAttribute(u"href") #$NON-NLS-1$
            elif relTypes.isUploadLink(rel,type):
                attrMap[ZAtomBlog.UPLOAD_LINK] = node.getAttribute(u"href") #$NON-NLS-1$
            elif relTypes.isCategoriesLink(rel,type):
                attrMap[ZAtomBlog.CATEGORIES_LINK] = node.getAttribute(u"href") #$NON-NLS-1$
            elif relTypes.isAlternateLink(rel,type):
                attrMap[ZAtomBlog.ALT_LINK] = node.getAttribute(u"href") #$NON-NLS-1$


        if not attrMap.has_key(ZAtomBlog.FEED_LINK) and attrMap.has_key(ZAtomBlog.POST_LINK):
            # feed url is same as this url.
            attrMap[ZAtomBlog.FEED_LINK] = self.url
        # check for required post link
        rVal = []
        if attrMap.has_key(ZAtomBlog.FEED_LINK) and attrMap.has_key(ZAtomBlog.POST_LINK):
            # this is a atom 1.0 feed.
            elem = self.getDom().selectSingleNode(u"/%sfeed/%sid"  % (prefix, prefix)) #$NON-NLS-1$
            if elem:
                attrMap[ZAtomBlog.ID] = elem.getText()
            elem = self.getDom().selectSingleNode(u"/%sfeed/%stitle" % (prefix, prefix))  #$NON-NLS-1$
            if elem:
                attrMap[ZAtomBlog.TITLE] = elem.getText()
            rVal = [attrMap]
        return rVal
Exemple #2
0
    def _getAtom10(self, prefix=u"atom:"):  #$NON-NLS-1$
        # find service.post and service.feed links
        attrMap = {}
        relTypes = ZAtomRelTypes()
        #TODO: find uploadLink and categoriesLink.
        for node in self.getDom().selectNodes(u"/%sfeed/%slink" %
                                              (prefix, prefix)):  #$NON-NLS-1$
            rel = node.getAttribute(u"rel")  #$NON-NLS-1$
            type = node.getAttribute(u"type")  #$NON-NLS-1$
            if relTypes.isFeedLink(rel, type):
                attrMap[ZAtomBlog.FEED_LINK] = node.getAttribute(
                    u"href")  #$NON-NLS-1$
            elif relTypes.isPostLink(rel, type):
                attrMap[ZAtomBlog.POST_LINK] = node.getAttribute(
                    u"href")  #$NON-NLS-1$
            elif relTypes.isUploadLink(rel, type):
                attrMap[ZAtomBlog.UPLOAD_LINK] = node.getAttribute(
                    u"href")  #$NON-NLS-1$
            elif relTypes.isCategoriesLink(rel, type):
                attrMap[ZAtomBlog.CATEGORIES_LINK] = node.getAttribute(
                    u"href")  #$NON-NLS-1$
            elif relTypes.isAlternateLink(rel, type):
                attrMap[ZAtomBlog.ALT_LINK] = node.getAttribute(
                    u"href")  #$NON-NLS-1$

        if not attrMap.has_key(ZAtomBlog.FEED_LINK) and attrMap.has_key(
                ZAtomBlog.POST_LINK):
            # feed url is same as this url.
            attrMap[ZAtomBlog.FEED_LINK] = self.url
        # check for required post link
        rVal = []
        if attrMap.has_key(ZAtomBlog.FEED_LINK) and attrMap.has_key(
                ZAtomBlog.POST_LINK):
            # this is a atom 1.0 feed.
            elem = self.getDom().selectSingleNode(
                u"/%sfeed/%sid" % (prefix, prefix))  #$NON-NLS-1$
            if elem:
                attrMap[ZAtomBlog.ID] = elem.getText()
            elem = self.getDom().selectSingleNode(
                u"/%sfeed/%stitle" % (prefix, prefix))  #$NON-NLS-1$
            if elem:
                attrMap[ZAtomBlog.TITLE] = elem.getText()
            rVal = [attrMap]
        return rVal
Exemple #3
0
    def _getAtom03(self):
        # find service.post and service.feed links
        titleMap = {}
        relTypes = ZAtomRelTypes()
        bPostLinkFound = False
        bFeedLinkFound = False  #@UnusedVariable
        for node in self.getDom().selectNodes(
                u"/atom03:feed/atom03:link"):  #$NON-NLS-1$
            attrMap = None
            title = node.getAttribute(u"title")  #$NON-NLS-1$
            if titleMap.has_key(title):
                attrMap = titleMap[title]
            else:
                attrMap = {}
                titleMap[title] = attrMap
                attrMap[ZAtomBlog.TITLE] = title

            rel = node.getAttribute(u"rel")  #$NON-NLS-1$
            type = node.getAttribute(u"type")  #$NON-NLS-1$

            if relTypes.isFeedLink(rel, type):
                attrMap[ZAtomBlog.FEED_LINK] = node.getAttribute(
                    u"href")  #$NON-NLS-1$
                bFeedLinkFound = True  #@UnusedVariable
            elif relTypes.isPostLink(rel, type):
                attrMap[ZAtomBlog.POST_LINK] = node.getAttribute(
                    u"href")  #$NON-NLS-1$
                attrMap[ZAtomBlog.ID] = attrMap[ZAtomBlog.POST_LINK]
                bPostLinkFound = True
            elif relTypes.isUploadLink(rel, type):
                attrMap[ZAtomBlog.UPLOAD_LINK] = node.getAttribute(
                    u"href")  #$NON-NLS-1$
            elif relTypes.isCategoriesLink(rel, type):
                attrMap[ZAtomBlog.CATEGORIES_LINK] = node.getAttribute(
                    u"href")  #$NON-NLS-1$
            elif relTypes.isAlternateLink(rel, type):
                attrMap[ZAtomBlog.ALT_LINK] = node.getAttribute(
                    u"href")  #$NON-NLS-1$
        rVal = []
        if bPostLinkFound:
            rVal = titleMap.values()
        return rVal
Exemple #4
0
    def _getAtom03(self):
        # find service.post and service.feed links
        titleMap = {}
        relTypes = ZAtomRelTypes()
        bPostLinkFound = False
        bFeedLinkFound = False #@UnusedVariable
        for node in self.getDom().selectNodes(u"/atom03:feed/atom03:link"): #$NON-NLS-1$
            attrMap = None
            title = node.getAttribute(u"title") #$NON-NLS-1$
            if titleMap.has_key(title):
                attrMap = titleMap[title]
            else:
                attrMap = {}
                titleMap[title] = attrMap
                attrMap[ZAtomBlog.TITLE] = title

            rel = node.getAttribute(u"rel") #$NON-NLS-1$
            type = node.getAttribute(u"type") #$NON-NLS-1$

            if relTypes.isFeedLink(rel, type):
                attrMap[ZAtomBlog.FEED_LINK] = node.getAttribute(u"href") #$NON-NLS-1$
                bFeedLinkFound = True #@UnusedVariable
            elif relTypes.isPostLink(rel,type):
                attrMap[ZAtomBlog.POST_LINK] = node.getAttribute(u"href") #$NON-NLS-1$
                attrMap[ZAtomBlog.ID] = attrMap[ZAtomBlog.POST_LINK]
                bPostLinkFound = True
            elif relTypes.isUploadLink(rel,type):
                attrMap[ZAtomBlog.UPLOAD_LINK] = node.getAttribute(u"href") #$NON-NLS-1$
            elif relTypes.isCategoriesLink(rel,type):
                attrMap[ZAtomBlog.CATEGORIES_LINK] = node.getAttribute(u"href") #$NON-NLS-1$
            elif relTypes.isAlternateLink(rel,type):
                attrMap[ZAtomBlog.ALT_LINK] = node.getAttribute(u"href") #$NON-NLS-1$
        rVal = []
        if bPostLinkFound:
            rVal = titleMap.values()
        return rVal