summaryrefslogtreecommitdiff
path: root/lib/spack/spack/spec.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/spack/spack/spec.py')
-rw-r--r--lib/spack/spack/spec.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index ced35d5c7d..78530f7a7c 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -4115,18 +4115,10 @@ class Spec(object):
clr.cwrite(f, stream=out, color=color)
def write_attribute(spec, attribute, color):
- current = spec
- if attribute.startswith("^"):
- attribute = attribute[1:]
- dep, attribute = attribute.split(".", 1)
- current = self[dep]
-
- if attribute == "":
- raise SpecFormatStringError("Format string attributes must be non-empty")
attribute = attribute.lower()
sig = ""
- if attribute[0] in "@%/":
+ if attribute.startswith(("@", "%", "/")):
# color sigils that are inside braces
sig = attribute[0]
attribute = attribute[1:]
@@ -4134,6 +4126,15 @@ class Spec(object):
sig = " arch=" # include space as separator
attribute = attribute[5:]
+ current = spec
+ if attribute.startswith("^"):
+ attribute = attribute[1:]
+ dep, attribute = attribute.split(".", 1)
+ current = self[dep]
+
+ if attribute == "":
+ raise SpecFormatStringError("Format string attributes must be non-empty")
+
parts = attribute.split(".")
assert parts
@@ -4162,9 +4163,9 @@ class Spec(object):
col = "#"
if ":" in attribute:
_, length = attribute.split(":")
- write(sig + morph(spec, spec.dag_hash(int(length))), col)
+ write(sig + morph(spec, current.dag_hash(int(length))), col)
else:
- write(sig + morph(spec, spec.dag_hash()), col)
+ write(sig + morph(spec, current.dag_hash()), col)
return
# Iterate over components using getattr to get next element