sregistry/main/registry/query.py
def label_search(self, key=None, value=None):
    '''search across labels'''

    if key is not None:
        key = key.lower()

    if value is not None:
        value = value.lower()

    show_details = True
    if key is None and value is None:
        url = '%s/labels/search' % (self.base)
        show_details = False

    elif key is not None and value is not None:
        url = '%s/labels/search/%s/key/%s/value' % (self.base, key, value)

    elif key is None:
        url = '%s/labels/search/%s/value' % (self.base, value)

    else:
        url = '%s/labels/search/%s/key' % (self.base, key)

    result = self._get(url)
    if len(result) == 0:
        bot.info("No labels found.")
        sys.exit(0)

    bot.info("Labels\n")

    rows = []
    for l in result:        
        if show_details is True:
            entry = ["%s:%s" %(l['key'],l['value']),
                     "\n%s\n\n" %"\n".join(l['containers'])]
        else:
            entry = ["N=%s" %len(l['containers']),
                    "%s:%s" %(l['key'],l['value']) ]
        rows.append(entry)
    bot.table(rows)
    return rows
def label_search(self, key=None, value=None):
    '''search across labels'''

    if key is not None:
        key = key.lower()

    if value is not None:
        value = value.lower()

    show_details = True
    if key is None and value is None:
        url = '%s/labels/search' % (self.base)
        show_details = False

    elif key is not None and value is not None:
        url = '%s/labels/search/%s/key/%s/value' % (self.base, key, value)

    elif key is None:
        url = '%s/labels/search/%s/value' % (self.base, value)

    else:
        url = '%s/labels/search/%s/key' % (self.base, key)

    result = self._get(url)
    if len(result) == 0:
        bot.info("No labels found.")
        sys.exit(0)

    bot.info("Labels\n")

    rows = []
    for l in result:        
        if show_details is True:
            entry = ["%s:%s" %(l['key'],l['value']),
                     "\n%s\n\n" %"\n".join(l['containers'])]
        else:
            entry = ["N=%s" %len(l['containers']),
                    "%s:%s" %(l['key'],l['value']) ]
        rows.append(entry)
    bot.table(rows)
    return rows
search across labels