summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-08-03 02:27:47 +0000
committerZac Medico <zmedico@gentoo.org>2006-08-03 02:27:47 +0000
commit656ccc792ac634338e92a6ff620292311029f4d5 (patch)
tree21df31fcbcb4bb879ad5c54ac9bceecd985c9eeb
parent63315f7f6c9c3157f81c7cfea7b4c6202f555a2f (diff)
downloadportage-656ccc792ac634338e92a6ff620292311029f4d5.tar.gz
portage-656ccc792ac634338e92a6ff620292311029f4d5.tar.bz2
portage-656ccc792ac634338e92a6ff620292311029f4d5.zip
Use a recursive function to simplify the walking of the profile paths. The number of parent profiles is constrained to 1 but could easily be extended to allow multiple inheritence.
svn path=/main/trunk/; revision=4091
-rw-r--r--pym/portage.py37
1 files changed, 20 insertions, 17 deletions
diff --git a/pym/portage.py b/pym/portage.py
index 7aef151e0..feb431dab 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -886,23 +886,26 @@ class config:
if self.profile_path is None:
self.profiles = []
else:
- self.profiles = [os.path.realpath(self.profile_path)]
- mypath = self.profiles[0]
- while os.path.exists(os.path.join(mypath, "parent")):
- parents_file = os.path.join(mypath, "parent")
- parents = grabfile(parents_file)
- if len(parents) != 1:
- raise portage_exception.ParseError(
- "Expected 1 parent and got %i: '%s'" % \
- (len(parents), parents_file))
- mypath = normalize_path(os.path.join(
- mypath, parents[0]))
- if os.path.exists(mypath):
- self.profiles.insert(0, mypath)
- else:
- raise portage_exception.ParseError(
- "Specified parent not found: '%s'" % parents_file)
-
+ self.profiles = []
+ def addProfile(currentPath):
+ parentsFile = os.path.join(currentPath, "parent")
+ if os.path.exists(parentsFile):
+ parents = grabfile(parentsFile)
+ if len(parents) != 1:
+ raise portage_exception.ParseError(
+ "Expected 1 parent and got %i: '%s'" % \
+ (len(parents), parents_file))
+ for parentPath in parents:
+ parentPath = normalize_path(os.path.join(
+ currentPath, parentPath))
+ if os.path.exists(parentPath):
+ addProfile(parentPath)
+ else:
+ raise portage_exception.ParseError(
+ "Parent '%s' not found: '%s'" % \
+ (parentPath, parentsFile))
+ self.profiles.append(currentPath)
+ addProfile(os.path.realpath(self.profile_path))
if os.environ.has_key("PORTAGE_CALLER") and os.environ["PORTAGE_CALLER"] == "repoman":
pass
else: