def _desc(self, entropy_server): """ Eit query desc code. """ repository_ids = [] if self._repository_id is None: repository_ids += entropy_server.repositories() else: repository_ids.append(self._repository_id) for repository_id in repository_ids: repo = entropy_server.open_repository(repository_id) key_sorter = lambda x: repo.retrieveAtom(x) for desc in self._nsargs.descriptions: pkg_ids = repo.searchDescription(desc, just_id = True) for pkg_id in sorted(pkg_ids, key = key_sorter): if self._quiet: entropy_server.output( repo.retrieveAtom(pkg_id), level="generic") else: print_package_info(pkg_id, entropy_server, repo, extended = self._verbose, strict_output = False, quiet = False) if not self._quiet: entropy_server.output( "[%s] %s %s" % ( darkgreen(desc), bold(str(len(pkg_ids))), teal(_("packages found")))) return 0
def _search(self, entropy_server): """ Actual Eit search code. """ if self._repository_id is None: repository_ids = entropy_server.repositories() else: repository_ids = [self._repository_id] for repository_id in repository_ids: repo = entropy_server.open_repository(repository_id) count = 0 for package in self._packages: results = repo.searchPackages( package, order_by = "atom") for result in results: count += 1 print_package_info( result[1], entropy_server, repo, installed_search = True, extended = True, quiet = self._quiet ) if not count and not self._quiet: entropy_server.output( purple(_("Nothing found")), importance=1, level="warning") return 0
def _match(self, entropy_server): """ Actual Eit match code. """ count = 0 for package in self._packages: pkg_id, pkg_repo = entropy_server.atom_match(package) if pkg_id == -1: continue count += 1 print_package_info( pkg_id, entropy_server, entropy_server.open_repository(pkg_repo), installed_search = True, extended = True, quiet = self._quiet ) if not count and not self._quiet: entropy_server.output( purple(_("Nothing found")), importance=1, level="warning") return 0
def _search(self, entropy_server, repository_id, repo): results = {} flatresults = {} reverse_symlink_map = self._settings()['system_rev_symlinks'] for xfile in self._paths: results[xfile] = set() pkg_ids = repo.searchBelongs(xfile) if not pkg_ids: # try real path if possible pkg_ids = repo.searchBelongs(os.path.realpath(xfile)) if not pkg_ids: # try using reverse symlink mapping for sym_dir in reverse_symlink_map: if xfile.startswith(sym_dir): for sym_child in reverse_symlink_map[sym_dir]: my_file = sym_child+xfile[len(sym_dir):] pkg_ids = repo.searchBelongs(my_file) if pkg_ids: break for pkg_id in pkg_ids: if not flatresults.get(pkg_id): results[xfile].add(pkg_id) flatresults[pkg_id] = True if results: key_sorter = lambda x: repo.retrieveAtom(x) for result in results: # print info xfile = result result = results[result] for pkg_id in sorted(result, key = key_sorter): if self._quiet: entropy_server.output( repo.retrieveAtom(pkg_id), level="generic") else: print_package_info(pkg_id, entropy_server, repo, installed_search = True, extended = self._verbose, quiet = self._quiet) if not self._quiet: entropy_server.output( "[%s] %s: %s %s" % ( purple(repository_id), darkgreen(xfile), bold(str(len(result))), teal(_("packages found")))) return 0
def _search(self, entropy_server, repository_id, repo): results = {} flatresults = {} reverse_symlink_map = self._settings()['system_rev_symlinks'] for xfile in self._paths: results[xfile] = set() pkg_ids = repo.searchBelongs(xfile) if not pkg_ids: # try real path if possible pkg_ids = repo.searchBelongs(os.path.realpath(xfile)) if not pkg_ids: # try using reverse symlink mapping for sym_dir in reverse_symlink_map: if xfile.startswith(sym_dir): for sym_child in reverse_symlink_map[sym_dir]: my_file = sym_child + xfile[len(sym_dir):] pkg_ids = repo.searchBelongs(my_file) if pkg_ids: break for pkg_id in pkg_ids: if not flatresults.get(pkg_id): results[xfile].add(pkg_id) flatresults[pkg_id] = True if results: key_sorter = lambda x: repo.retrieveAtom(x) for result in results: # print info xfile = result result = results[result] for pkg_id in sorted(result, key=key_sorter): if self._quiet: entropy_server.output(repo.retrieveAtom(pkg_id), level="generic") else: print_package_info(pkg_id, entropy_server, repo, installed_search=True, extended=self._verbose, quiet=self._quiet) if not self._quiet: entropy_server.output( "[%s] %s: %s %s" % (purple(repository_id), darkgreen(xfile), bold(str(len(result))), teal(_("packages found")))) return 0
def _required(self, entropy_server): """ Eit query required code. """ repository_ids = [] if self._repository_id is None: repository_ids += entropy_server.repositories() else: repository_ids.append(self._repository_id) exit_st = 0 key_sorter = lambda x: entropy_server.open_repository( x[1]).retrieveAtom(x[0]) for library in self._nsargs.libraries: pkg_matches = set() for repository_id in repository_ids: repo = entropy_server.open_repository(repository_id) package_ids = repo.searchNeeded(library, like=True) pkg_matches.update( [(x, repository_id) for x in package_ids]) matches = sorted(pkg_matches, key=key_sorter) for package_id, repository_id in matches: repo = entropy_server.open_repository(repository_id) if self._quiet: atom = repo.retrieveAtom(package_id) entropy_server.output(atom, level="generic") else: print_package_info( package_id, entropy_server, repo, quiet=False) if not matches and not self._quiet: entropy_server.output( "%s: %s" % ( purple(_("Nothing found for")), teal(library) ), importance=1, level="warning") if not matches: exit_st = 1 return exit_st
def _revdeps(self, entropy_server): """ Eit query revdeps code. """ excluded_dep_types = None if not self._nsargs.bdeps: excluded_dep_types = [ etpConst['dependency_type_ids']['bdepend_id'] ] exit_st = 0 for package in self._nsargs.packages: package_id, repository_id = entropy_server.atom_match(package) if package_id == -1: if not self._quiet: entropy_server.output( "%s: %s" % ( purple(_("Not matched")), teal(package)), level="warning", importance=1) exit_st = 1 continue repo = entropy_server.open_repository(repository_id) key_sorter = lambda x: repo.retrieveAtom(x) results = repo.retrieveReverseDependencies(package_id, exclude_deptypes = excluded_dep_types) for pkg_id in sorted(results, key = key_sorter): print_package_info(pkg_id, entropy_server, repo, installed_search = True, strict_output = self._quiet, extended = self._verbose, quiet = self._quiet) if not self._quiet: atom = repo.retrieveAtom(package_id) entropy_server.output( "[%s] %s: %s %s" % ( purple(repository_id), darkgreen(atom), bold(str(len(results))), teal(_("revdep(s) found")))) return exit_st
def _match(self, entropy_server): """ Actual Eit match code. """ count = 0 for package in self._packages: pkg_id, pkg_repo = entropy_server.atom_match(package) if pkg_id == -1: continue count += 1 print_package_info(pkg_id, entropy_server, entropy_server.open_repository(pkg_repo), installed_search=True, extended=True, quiet=self._quiet) if not count and not self._quiet: entropy_server.output(purple(_("Nothing found")), importance=1, level="warning") return 0
def _tags(self, entropy_server): """ Eit query tags code. """ repository_ids = [] if self._repository_id is None: repository_ids += entropy_server.repositories() else: repository_ids.append(self._repository_id) exit_st = 0 for repository_id in repository_ids: repo = entropy_server.open_repository(repository_id) key_sorter = lambda x: repo.retrieveAtom(x[1]) for tag in self._nsargs.tags: tagged_pkgs = repo.searchTaggedPackages( tag, atoms = True) results = sorted(tagged_pkgs, key = key_sorter) for atom, pkg_id in results: if self._quiet: entropy_server.output(atom, level="generic") else: print_package_info(pkg_id, entropy_server, repo, quiet = False) if (not results) and (not self._quiet): entropy_server.output( "%s: %s" % ( purple(_("Nothing found for")), teal(tag) ), importance=1, level="warning") if not results: exit_st = 1 return exit_st