(self, expression, url, lines=22, official=None)
Search results from Docker Hub using v2 API
Search results from Docker Hub using v2 API
Search results from Docker Hub using v2 API
def search_get_page_v2(self, expression, url, lines=22, official=None):
        """Search results from Docker Hub using v2 API"""
        if not expression:
            expression = '*'
        if expression and official is None:
            url = url + \
                    "/v2/search/repositories?query=%s" % (expression)
        elif expression and official is True:
            url = url + \
                    "/v2/search/repositories?query=%s&is_official=%s" \
                    % (expression, "true")
        elif expression and official is False:
            url = url + \
                    "/v2/search/repositories?query=%s&is_official=%s" \
                    % (expression, "false")
        else:
            return []
        url += "&page_size=%d" % (lines)
        if self.search_page != 1:
            url += "&page=%d" % (self.search_page)
        (dummy, buf) = self._get_url(url)
        try:
            repo_list = json.loads(buf.getvalue())
            if repo_list["count"] == self.search_page:
                self.search_ended = True
            return repo_list
        except (IOError, OSError, AttributeError, KeyError,
                ValueError, TypeError):
            self.search_ended = True
            return []
def search_get_page_v2 ( self , expression , url , lines = 22 , official = None ) : if not expression : expression = '*' if expression and official is None : url = url + "/v2/search/repositories?query=%s" % ( expression ) elif expression and official is True : url = url + "/v2/search/repositories?query=%s&is_official=%s" % ( expression , "true" ) elif expression and official is False : url = url + "/v2/search/repositories?query=%s&is_official=%s" % ( expression , "false" ) else : return [ ] url += "&page_size=%d" % ( lines ) if self . search_page != 1 : url += "&page=%d" % ( self . search_page ) ( dummy , buf ) = self . _get_url ( url ) try : repo_list = json . loads ( buf . getvalue ( ) ) if repo_list [ "count" ] == self . search_page : self . search_ended = True return repo_list except ( IOError , OSError , AttributeError , KeyError , ValueError , TypeError ) : self . search_ended = True return [ ]