summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/view.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/spack/spack/cmd/view.py b/lib/spack/spack/cmd/view.py
index b504dfd2b1..caf14bfa53 100644
--- a/lib/spack/spack/cmd/view.py
+++ b/lib/spack/spack/cmd/view.py
@@ -317,16 +317,19 @@ visitor_check = visitor_statlink
def visitor_print(specs, args):
'Print a string for each spec using args.format.'
fmt = args.format[0]
+ from string import Template
+ t = Template(fmt)
+
for spec in specs:
kwds = spec2dict(spec)
try:
- string = fmt.format(**kwds)
+ text = t.substitute(kwds)
except KeyError:
tty.error("Format error, use keywords: %s" % (', '.join(kwds.keys()), ))
raise
# argparser escapes these
- string = string.replace(r'\n', '\n').replace(r'\t', '\t')
- sys.stdout.write(string)
+ text = text.replace(r'\n', '\n').replace(r'\t', '\t')
+ sys.stdout.write(text)
# Finally, the actual "view" command. There should be no need to