Skip to content
Snippets Groups Projects
Commit 8ddc1f89 authored by Brett Viren's avatar Brett Viren
Browse files

Move from str.format() to string.Template.

parent f1900f6a
No related branches found
No related tags found
No related merge requests found
......@@ -317,16 +317,19 @@ def visitor_statlink(specs, args):
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment