def list(server, url_base, url_extra, headers): """ Get and decode json from url """ get_data = utils.GET(server=server, url=url_base+url_extra, headers=headers) data = utils.deserialize(get_data) return data
def search(args): """ /search """ url_base = '/search' url_extra = '' url_extra += ('?', '&')[bool(url_extra)] + 'cat=' + args.category if args.category else '' url_extra += ('?', '&')[bool(url_extra)] + 'pkg=' + args.package if args.package else '' url_extra += ('?', '&')[bool(url_extra)] + 'ver=' + args.version if args.version else '' url_extra += ('?', '&')[bool(url_extra)] + 'repo=' + args.repo if args.repo else '' url_extra += ('?', '&')[bool(url_extra)] + 'min_hosts=' + str(args.min_hosts) if args.min_hosts else '' url_extra += ('?', '&')[bool(url_extra)] + 'max_hosts=' + str(args.max_hosts) if args.max_hosts else '' get_data = utils.GET(server = args.server, url = args.url + url_base + url_extra, headers = utils.headers) data = utils.deserialize(get_data) pprint ('Search results', data)