diff options
Diffstat (limited to 'lib/spack/spack/spec.py')
-rw-r--r-- | lib/spack/spack/spec.py | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index a0ab38c049..dffdccaddb 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -553,6 +553,13 @@ class Spec(object): @property + def cshort_spec(self): + """Returns a version of the spec with the dependencies hashed + instead of completely enumerated.""" + return self.format('$_$@$%@$+$=$#', color=True) + + + @property def prefix(self): return Prefix(spack.install_layout.path_for_spec(self)) @@ -712,6 +719,15 @@ class Spec(object): raise InconsistentSpecError("Invalid Spec DAG: %s" % e.message) + def index(self): + """Return DependencyMap that points to all the dependencies in this + spec.""" + dm = DependencyMap() + for spec in self.traverse(): + dm[spec.name] = spec + return dm + + def flatten(self): """Pull all dependencies up to the root (this spec). Merge constraints for dependencies with the same name, and if they @@ -858,7 +874,7 @@ class Spec(object): def normalized(self): """Return a normalized copy of this spec without modifying this spec.""" clone = self.copy() - clone.normalized() + clone.normalize() return clone @@ -1096,8 +1112,9 @@ class Spec(object): def __contains__(self, spec): - """True if this spec has any dependency that satisfies the supplied - spec.""" + """True if this spec satisfis the provided spec, or if any dependency + does. If the spec has no name, then we parse this one first. + """ spec = self._autospec(spec) for s in self.traverse(): if s.satisfies(spec): @@ -1288,12 +1305,13 @@ class Spec(object): def tree(self, **kwargs): """Prints out this spec and its dependencies, tree-formatted with indentation.""" - color = kwargs.get('color', False) - depth = kwargs.get('depth', False) - showid = kwargs.get('ids', False) - cover = kwargs.get('cover', 'nodes') - indent = kwargs.get('indent', 0) - format = kwargs.get('format', '$_$@$%@$+$=') + color = kwargs.pop('color', False) + depth = kwargs.pop('depth', False) + showid = kwargs.pop('ids', False) + cover = kwargs.pop('cover', 'nodes') + indent = kwargs.pop('indent', 0) + fmt = kwargs.pop('format', '$_$@$%@$+$=') + check_kwargs(kwargs, self.tree) out = "" cur_id = 0 @@ -1310,7 +1328,7 @@ class Spec(object): out += (" " * d) if d > 0: out += "^" - out += node.format(format, color=color) + "\n" + out += node.format(fmt, color=color) + "\n" return out |