From 415650cf5b637aa8486754ce946239c37c548894 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 5 Jul 2007 06:55:03 +0000 Subject: [PATCH] Merge portdbapi.getRepositories() from trunk. svn path=/main/branches/2.1.2/; revision=7158 --- pym/portage.py | 29 +++++++++++++++++++++++++++++ pym/portage_const.py | 8 +++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/pym/portage.py b/pym/portage.py index 3552f8e44..f651ddc59 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -5854,6 +5854,17 @@ class portdbapi(dbapi): self.porttrees = [self.porttree_root] + \ [os.path.realpath(t) for t in self.mysettings["PORTDIR_OVERLAY"].split()] + self.treemap = {} + for path in self.porttrees: + repo_name_path = os.path.join(path, portage_const.REPO_NAME_LOC) + try: + repo_name = open(repo_name_path, 'r').readline().strip() + self.treemap[repo_name] = path + except (OSError,IOError): + writemsg("Note: The repository at %s does not have a profiles/repo_name entry.\n" % path \ + + " This can reduce the functionality of the repository in some cases.\n") + pass + self.auxdbmodule = self.mysettings.load_best_module("portdbapi.auxdbmodule") self.auxdb = {} self._init_cache_dirs() @@ -5926,6 +5937,24 @@ class portdbapi(dbapi): def findname(self,mycpv): return self.findname2(mycpv)[0] + def getRepositoryPath(self, repository_id): + """ + This function is required for GLEP 42 compliance; given a valid repository ID + it must return a path to the repository + TreeMap = { id:path } + """ + if repository_id in self.treemap: + return self.treemap[repository_id] + return None + + def getRepositories(self): + """ + This function is required for GLEP 42 compliance; it will return a list of + repository ID's + TreeMap = {id: path} + """ + return [k for k in self.treemap if k] + def findname2(self, mycpv, mytree=None): """ Returns the location of the CPV, and what overlay it was in. diff --git a/pym/portage_const.py b/pym/portage_const.py index 4f0d04ecb..2b33f2013 100644 --- a/pym/portage_const.py +++ b/pym/portage_const.py @@ -44,7 +44,13 @@ CUSTOM_MIRRORS_FILE = USER_CONFIG_PATH+"/mirrors" CONFIG_MEMORY_FILE = PRIVATE_PATH + "/config" COLOR_MAP_FILE = USER_CONFIG_PATH + "/color.map" -INCREMENTALS=["USE","USE_EXPAND","USE_EXPAND_HIDDEN","FEATURES","ACCEPT_KEYWORDS","ACCEPT_LICENSE","CONFIG_PROTECT_MASK","CONFIG_PROTECT","PRELINK_PATH","PRELINK_PATH_MASK"] +REPO_NAME_FILE = "repo_name" +REPO_NAME_LOC = "profiles" + "/" + REPO_NAME_FILE + +INCREMENTALS = ["USE", "USE_EXPAND", "USE_EXPAND_HIDDEN", "FEATURES", + "ACCEPT_KEYWORDS", "ACCEPT_LICENSE", + "CONFIG_PROTECT_MASK", "CONFIG_PROTECT", + "PRELINK_PATH", "PRELINK_PATH_MASK"] EBUILD_PHASES = ["setup", "unpack", "compile", "test", "install", "preinst", "postinst", "prerm", "postrm", "other"] -- 2.26.2