def _repoquery(query_type, q, pool, fmt=api.QueryFormat.JSON): query = api.Query(pool) if query_type == "whoneeds": return query.whoneeds(q, fmt) if query_type == "depends": return query.depends(q, fmt) if query_type == "search": return query.find(q, fmt)
def repoquery(args, parser): prefix = context.target_prefix init_api_context() index_args = { 'use_cache': args.use_index_cache, 'channel_urls': context.channels, 'unknown': args.unknown, 'prepend': not args.override_channels, 'use_local': args.use_local } installed_json_f = get_installed_jsonfile(prefix) pool = api.Pool() repos = [] # add installed repo = api.Repo(pool, "installed", installed_json_f.name, "") repo.set_installed() repos.append(repo) only_installed = True if args.subcmd == "search" and args.installed == False: only_installed = False elif args.all_channels: only_installed = False if not only_installed: index = get_index(channel_urls=index_args['channel_urls'], prepend=index_args['prepend'], platform=None, use_local=index_args['use_local'], use_cache=index_args['use_cache'], unknown=index_args['unknown'], prefix=prefix) for subdir, channel in index: if subdir.loaded() == False and channel.platform != 'noarch': # ignore non-loaded subdir if channel is != noarch continue repo = api.Repo(pool, str(channel), subdir.cache_path(), channel.url(with_credentials=True)) repo.set_priority(0, 0) repos.append(repo) if not context.json: print("\nExecuting the query %s\n" % args.package_query) query = api.Query(pool) if args.subcmd == "whoneeds": query.whoneeds(args.package_query, args.tree) if args.subcmd == "depends": query.depends(args.package_query) if args.subcmd == "search": query.find(args.package_query)
def repoquery(args, parser): prepend = not args.override_channels prefix = context.target_prefix init_api_context() index_args = { 'use_cache': args.use_index_cache, 'channel_urls': context.channels, 'unknown': args.unknown, 'prepend': not args.override_channels, 'use_local': args.use_local } index = get_index(channel_urls=index_args['channel_urls'], prepend=index_args['prepend'], platform=None, use_local=index_args['use_local'], use_cache=index_args['use_cache'], unknown=index_args['unknown'], prefix=prefix) installed_json_f = get_installed_jsonfile(prefix) pool = api.Pool() repos = [] # add installed repo = api.Repo(pool, "installed", installed_json_f.name, "") repo.set_installed() repos.append(repo) if not args.installed: for subdir, channel in index: repo = api.Repo(pool, str(channel), subdir.cache_path(), channel.url(with_credentials=True)) repo.set_priority(0, 0) repos.append(repo) print("\nExecuting the query %s\n" % args.query) query = api.Query(pool) if args.whatrequires: print(query.whatrequires(args.query)) elif args.tree: print(query.dependencytree(args.query)) else: print(query.find(args.query))
def repoquery(args, parser): if not args.subcmd: print("repoquery needs a subcommand (search, depends or whoneeds)") print("eg:") print(" $ mamba repoquery search xtensor\n") exit(1) if args.platform: context._subdirs = (args.platform, 'noarch') prefix = context.target_prefix init_api_context() index_args = { 'use_cache': args.use_index_cache, 'channel_urls': context.channels, 'unknown': args.unknown, 'prepend': not args.override_channels, 'use_local': args.use_local } installed_json_f, installed_pkg_recs = get_installed_jsonfile(prefix) pool = api.Pool() repos = [] only_installed = True if args.subcmd == "search" and args.installed == False: only_installed = False elif args.all_channels or len(args.channel): only_installed = False if only_installed and args.no_installed: print("No channels selected.") print("Activate -a to search all channels.") exit(1) if not args.no_installed: # add installed repo = api.Repo(pool, "installed", installed_json_f.name, "") repo.set_installed() repos.append(repo) if not only_installed: index = get_index(channel_urls=index_args['channel_urls'], prepend=index_args['prepend'], platform=None, use_local=index_args['use_local'], use_cache=index_args['use_cache'], unknown=index_args['unknown'], prefix=prefix) for subdir, channel in index: if subdir.loaded() == False and channel.platform != 'noarch': # ignore non-loaded subdir if channel is != noarch continue repo = api.Repo(pool, str(channel), subdir.cache_path(), channel.url(with_credentials=True)) repo.set_priority(0, 0) repos.append(repo) if not context.json: print("\nExecuting the query %s\n" % args.package_query) query = api.Query(pool) if args.subcmd == "whoneeds": query.whoneeds(args.package_query, args.tree) if args.subcmd == "depends": query.depends(args.package_query) if args.subcmd == "search": query.find(args.package_query)