7 _this_dir = os.path.dirname(__file__)
10 def write_problemlist(problem_dir=None, blacklist=()):
11 # remove evidence from previous runs
12 for name in os.listdir(_this_dir):
13 if os.path.islink(name):
16 # generate new symlinks and problemlist.tex
17 f = open(os.path.join(_this_dir, 'problemlist.tex'), 'w')
19 for source in sorted(os.listdir(problem_dir)):
20 if source in blacklist:
22 source_dir = os.path.join(problem_dir, source)
23 if not os.path.isdir(source_dir):
25 f.write('\section{%s}' % source.replace('_', ' '))
26 for problem in sorted(os.listdir(source_dir)):
27 path = os.path.join(source_dir, problem)
28 if os.path.isfile(path):
29 relpath = os.path.relpath(path, _this_dir)
30 if path.endswith('.tex'):
31 pname = 'problem%d.tex' % i
33 f.write('\\input{%s}\n' % pname)
34 else: # utility file (e.g. image)
36 os.symlink(relpath, pname)
40 if __name__ == '__main__':
42 problem_dir=os.path.join(_this_dir, '..', 'problems'),
45 'Serway_and_Jewett_4',
46 'Serway_and_Jewett_4_venkat',
47 'Serway_and_Jewett_4_wking',
48 # 'Serway_and_Jewett_8',
50 'Thornton_and_Rex_3_wking',
51 'Young_and_Freedman_12',