def walkPackagePath(self, path):
"""Legacy path walking.
Does not support any advanced query features. Guarenteed to return only
a single package. If any path element is not found a error is thrown.
"""
# replace aliases
path = self.__substAlias(path)
# walk packages
thisPackage = self.getRootPackage()
steps = [ s for s in path.split("/") if s != "" ]
if steps == []:
raise BobError("'{}' is not a valid package path".format(path))
for step in steps:
nextPackages = { s.getPackage().getName() : s.getPackage()
for s in thisPackage.getDirectDepSteps() }
for s in thisPackage.getIndirectDepSteps():
p = s.getPackage()
nextPackages.setdefault(p.getName(), p)
if step not in nextPackages:
stack = thisPackage.getStack()
raise BobError("Package '{}' not found under '{}'"
.format(step, "/".join(stack) if stack != [''] else "/"))
thisPackage = nextPackages[step]
return thisPackage
评论列表
文章目录