blob: 4e00dc5e00bf81bf52847687195114b7859f7139 (
plain)
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
38
39
40
41
|
#!/usr/bin/env python
import glob
import os.path
import os
from bson.son import SON
import sys
def print_instructions(p, fname):
try:
print "---------------"
l = p.split(os.sep)
l1 = []
for i in xrange(len(l)):
f = os.path.join(*l[:i+1])
if os.path.islink(f):
s = "{0} ({1})".format(l[i], os.path.split(os.readlink(f))[1])
else:
s = l[i]
l1.append(s)
print p
print " - ".join(l1)
with open(os.path.join(p, fname)) as f:
task_code = compile(f.read(), fname, 'exec')
exec(task_code)
for lang, text in instructions.iteritems():
print("Language: {0}".format(lang))
print(text.encode('utf-8'))
print("")
except Exception, e:
print e
pass
if __name__ == '__main__':
l = glob.glob(sys.argv[1])
l.sort()
for d in l:
for root, dirs, files in os.walk(d, followlinks=True):
for fname in files:
if fname == 'task.py':
print_instructions(root, fname)
|