diff options
author | Brett Viren <brett.viren@gmail.com> | 2016-05-14 09:11:04 -0400 |
---|---|---|
committer | Brett Viren <brett.viren@gmail.com> | 2016-05-14 09:11:04 -0400 |
commit | 8ddc1f89778335dda3d1dd213e75bc3a92d99712 (patch) | |
tree | a7a88f4afaf35df2a5e6febb411dbdb8b6de2f63 /lib | |
parent | f1900f6a7b080a6b45392d356749e2a98de46398 (diff) | |
download | spack-8ddc1f89778335dda3d1dd213e75bc3a92d99712.tar.gz spack-8ddc1f89778335dda3d1dd213e75bc3a92d99712.tar.bz2 spack-8ddc1f89778335dda3d1dd213e75bc3a92d99712.tar.xz spack-8ddc1f89778335dda3d1dd213e75bc3a92d99712.zip |
Move from str.format() to string.Template.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/cmd/view.py | 9 |
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 |