From: Arfrever Frehtes Taifersar Arahesis Date: Sun, 14 Jul 2013 18:39:14 +0000 (+0200) Subject: portageq: Use uses_eroot decorator. X-Git-Tag: v2.2.0_alpha189~50 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7e1e2fc9709fd30a460b9bc83c1f612d79378cca;p=portage.git portageq: Use uses_eroot decorator. --- diff --git a/bin/portageq b/bin/portageq index c5c37d9b7..990d1bfd0 100755 --- a/bin/portageq +++ b/bin/portageq @@ -58,6 +58,10 @@ def eval_atom_use(atom): atom = atom.evaluate_conditionals(use) return atom +def uses_eroot(function): + function.uses_eroot = True + return function + #----------------------------------------------------------------------------- # # To add functionality to this tool, add a function below. @@ -79,6 +83,7 @@ def eval_atom_use(atom): # and will automaticly add a command by the same name as the function! # +@uses_eroot def has_version(argv): """ Return code 0 if it's available, 1 otherwise. @@ -122,9 +127,9 @@ def has_version(argv): portage.writemsg("ERROR: Invalid atom: '%s'\n" % argv[1], noiselevel=-1) return 2 -has_version.uses_eroot = True +@uses_eroot def best_version(argv): """ Returns category/package-version (without .ebuild). @@ -161,9 +166,9 @@ def best_version(argv): print(portage.best(mylist)) except KeyError: return 1 -best_version.uses_eroot = True +@uses_eroot def mass_best_version(argv): """ []+ Returns category/package-version (without .ebuild). @@ -177,8 +182,9 @@ def mass_best_version(argv): print(pack+":"+portage.best(mylist)) except KeyError: return 1 -mass_best_version.uses_eroot = True + +@uses_eroot def metadata(argv): if (len(argv) < 4): print("ERROR: insufficient parameters!", file=sys.stderr) @@ -211,8 +217,8 @@ Available keys: %s """ % ','.join(sorted(x for x in portage.auxdbkeys \ if not x.startswith('UNUSED_'))) -metadata.uses_eroot = True +@uses_eroot def contents(argv): """ List the files that are installed for a given package, with @@ -233,8 +239,9 @@ def contents(argv): treetype="vartree", vartree=vartree) writemsg_stdout(''.join('%s\n' % x for x in sorted(db.getcontents())), noiselevel=-1) -contents.uses_eroot = True + +@uses_eroot def owners(argv): """ []+ Given a list of files, print the packages that own the files and which @@ -313,8 +320,8 @@ def owners(argv): return 0 return 1 -owners.uses_eroot = True +@uses_eroot def is_protected(argv): """ Given a single filename, return code 0 if it's protected, 1 otherwise. @@ -360,8 +367,8 @@ def is_protected(argv): return 0 return 1 -is_protected.uses_eroot = True +@uses_eroot def filter_protected(argv): """ Read filenames from stdin and write them to stdout if they are protected. @@ -420,8 +427,8 @@ def filter_protected(argv): return 0 -filter_protected.uses_eroot = True +@uses_eroot def best_visible(argv): """ [pkgtype] Returns category/package-version (without .ebuild). @@ -502,9 +509,9 @@ def best_visible(argv): writemsg_stdout("\n", noiselevel=-1) return 1 -best_visible.uses_eroot = True +@uses_eroot def mass_best_visible(argv): """ [] []+ Returns category/package-version (without .ebuild). @@ -529,9 +536,9 @@ def mass_best_visible(argv): best_visible([root, pkgtype, pack]) except KeyError: return 1 -mass_best_visible.uses_eroot = True +@uses_eroot def all_best_visible(argv): """ Returns all best_visible packages (without .ebuild). @@ -546,9 +553,9 @@ def all_best_visible(argv): mybest=portage.best(portage.db[argv[0]]["porttree"].dbapi.match(pkg)) if mybest: print(mybest) -all_best_visible.uses_eroot = True +@uses_eroot def match(argv): """ Returns a \\n separated list of category/package-version. @@ -595,8 +602,9 @@ def match(argv): results = vardb.match(atom) for cpv in results: print(cpv) -match.uses_eroot = True + +@uses_eroot def expand_virtual(argv): """ Returns a \\n separated list of atoms expanded from a @@ -631,7 +639,6 @@ def expand_virtual(argv): return os.EX_OK -expand_virtual.uses_eroot = True def vdb_path(argv): """ @@ -650,6 +657,7 @@ def gentoo_mirrors(argv): print(portage.settings["GENTOO_MIRRORS"]) +@uses_eroot def repositories_configuration(argv): """ Returns the configuration of repositories. @@ -659,7 +667,6 @@ def repositories_configuration(argv): return 3 sys.stdout.write(portage.db[argv[0]]["vartree"].settings.repositories.config_string()) sys.stdout.flush() -repositories_configuration.uses_eroot = True def portdir(argv): @@ -730,6 +737,8 @@ def envvar(argv): else: print(portage.settings[arg]) + +@uses_eroot def get_repos(argv): """ Returns all repos with names (repo_name file) argv[0] = $EROOT @@ -739,8 +748,8 @@ def get_repos(argv): return 2 print(" ".join(reversed(portage.db[argv[0]]["vartree"].settings.repositories.prepos_order))) -get_repos.uses_eroot = True +@uses_eroot def master_repositories(argv): """ + Returns space-separated list of master repositories for specified repository. @@ -760,8 +769,8 @@ def master_repositories(argv): else: print(" ".join(x.name for x in repo.masters)) -master_repositories.uses_eroot = True +@uses_eroot def get_repo_path(argv): """ + Returns the path to the repo named argv[1], argv[0] = $EROOT @@ -779,8 +788,8 @@ def get_repo_path(argv): return 1 print(path) -get_repo_path.uses_eroot = True +@uses_eroot def available_eclasses(argv): """ + Returns space-separated list of available eclasses for specified repository. @@ -800,8 +809,8 @@ def available_eclasses(argv): else: print(" ".join(sorted(repo.eclass_db.eclasses))) -available_eclasses.uses_eroot = True +@uses_eroot def eclass_path(argv): """ + Returns the path to specified eclass for specified repository. @@ -829,8 +838,8 @@ def eclass_path(argv): print(eclass.location) return retval -eclass_path.uses_eroot = True +@uses_eroot def license_path(argv): """ + Returns the path to specified license for specified repository. @@ -860,8 +869,8 @@ def license_path(argv): print(eclass_path) return retval -license_path.uses_eroot = True +@uses_eroot def list_preserved_libs(argv): """ Print a list of libraries preserved during a package update in the form @@ -883,7 +892,7 @@ def list_preserved_libs(argv): msg.append('\n') writemsg_stdout(''.join(msg), noiselevel=-1) return rValue -list_preserved_libs.uses_eroot = True + class MaintainerEmailMatcher(object): def __init__(self, maintainer_emails): @@ -906,6 +915,8 @@ class HerdMatcher(object): herds = self._herds return any(x in herds for x in metadata_xml.herds()) + +@uses_eroot def pquery(parser, pquery_option_groups, opts, args): """[options] [atom]+ Emulates a subset of Pkgcore's pquery tool. @@ -1089,14 +1100,13 @@ def pquery(parser, pquery_option_groups, opts, args): return os.EX_OK -pquery.uses_eroot = False #----------------------------------------------------------------------------- # # DO NOT CHANGE CODE BEYOND THIS POINT - IT'S NOT NEEDED! # -non_commands = frozenset(['elog', 'eval_atom_use', 'exithandler', 'main', 'usage']) +non_commands = frozenset(['elog', 'eval_atom_use', 'exithandler', 'main', 'usage', 'uses_eroot']) commands = sorted(k for k, v in globals().items() \ if k not in non_commands and isinstance(v, types.FunctionType) and v.__module__ == "__main__")