sapling/tests/heredoctest.py
Pulkit Goyal aef2bdd39a py3: make files use absolute_import and print_function
This patch includes addition of absolute_import and print_function to the
 files where they are missing. The modern importing conventions are also followed.
2016-07-03 22:28:24 +05:30

21 lines
526 B
Python

from __future__ import absolute_import, print_function
import sys
globalvars = {}
lines = sys.stdin.readlines()
while lines:
l = lines.pop(0)
if l.startswith('SALT'):
print(l[:-1])
elif l.startswith('>>> '):
snippet = l[4:]
while lines and lines[0].startswith('... '):
l = lines.pop(0)
snippet += l[4:]
c = compile(snippet, '<heredoc>', 'single')
try:
exec(c, globalvars)
except Exception as inst:
print(repr(inst))