-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.py
More file actions
37 lines (30 loc) · 718 Bytes
/
run.py
File metadata and controls
37 lines (30 loc) · 718 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
try:
import ast
except ImportError:
ast = None
import glob
import sys
try:
sorted
except NameError:
def sorted(t):
t2 = list(t)
t2.sort()
return t2
def main():
for f in sorted(glob.glob("examples/*.py")):
fo = open(f)
data = fo.read()
fo.close()
try:
if ast:
ast.parse(data)
else:
# Note that __future__ imports here leak into this compile, so
# we can't use any.
compile(data, "<eval>", "exec")
sys.stdout.write(f + " YES\n")
except SyntaxError:
sys.stdout.write(f + " NO\n")
if __name__ == "__main__":
main()