From: W. Trevor King Date: Thu, 12 Apr 2012 07:50:44 +0000 (-0400) Subject: Clean up latex test harness and build all but Serway and Jewett v4. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=902ab2fa6cafa1fd8e739e3f63ddadc2b84c954c;p=course.git Clean up latex test harness and build all but Serway and Jewett v4. --- diff --git a/latex/test/Makefile b/latex/test/Makefile index 7ed6b11..61b8790 100644 --- a/latex/test/Makefile +++ b/latex/test/Makefile @@ -11,7 +11,7 @@ view : all xpdf probs.pdf & xpdf sols.pdf & -%.pdf : %.tex $(SOURCE_FILES) problemlist.tex +%.pdf : %.tex $(SOURCE_FILES) problemlist.tex python-images pdflatex $(patsubst %.tex,%,$<) find . -name '*.asy' -execdir asy -noprc -render=0 {} \; pdflatex $(patsubst %.tex,%,$<) @@ -20,12 +20,20 @@ view : all problemlist.tex : write_problemlist.py ./$< +python-images: problemlist.tex + for SCRIPT in *.py; do \ + if [ -L "$${SCRIPT}" ]; then \ + TARGET="$$(echo "$${SCRIPT}" | awk -F. '{print $$(NF-1)}').png"; \ + "./$${SCRIPT}" "$${TARGET}"; \ + fi \ + done + semi-clean : rm -f *.log *.aux *.out *.thm *.toc *.pre *-*[0-9].tex *.js *.prc *.asy clean : semi-clean rm -f *.pdf $(DIST_FILE) $(DIST_DIR) install* - rm -f problemlist.tex $(shell find . -type l) + rm -f problemlist.tex *.png $(shell find . -type l) $(DIST_FILE) : $(DIST_FILES) mkdir $(DIST_DIR) diff --git a/latex/test/probs.tex b/latex/test/probs.tex index fa21ac1..2e8ed00 100644 --- a/latex/test/probs.tex +++ b/latex/test/probs.tex @@ -1,4 +1,5 @@ \documentclass[letterpaper, 10pt]{article} +\usepackage{etex} \PassOptionsToPackage{nosolutions}{problempack} diff --git a/latex/test/sols.tex b/latex/test/sols.tex index 1596819..6d56e07 100644 --- a/latex/test/sols.tex +++ b/latex/test/sols.tex @@ -1,4 +1,5 @@ \documentclass[letterpaper, 10pt]{article} +\usepackage{etex} \PassOptionsToPackage{solutions,loose}{problempack} diff --git a/latex/test/write_problemlist.py b/latex/test/write_problemlist.py index 2e3ef27..fe3fae2 100755 --- a/latex/test/write_problemlist.py +++ b/latex/test/write_problemlist.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import hashlib import os import os.path @@ -7,7 +8,7 @@ import os.path _this_dir = os.path.dirname(__file__) -def write_problemlist(problem_dir=None, blacklist=()): +def write_problemlist(problem_dir=None, blacklist=(), symlink=False): # remove evidence from previous runs for name in os.listdir(_this_dir): if os.path.islink(name): @@ -15,7 +16,8 @@ def write_problemlist(problem_dir=None, blacklist=()): # generate new symlinks and problemlist.tex f = open(os.path.join(_this_dir, 'problemlist.tex'), 'w') - i = 1 + if symlink: + i = 1 for source in sorted(os.listdir(problem_dir)): if source in blacklist: continue @@ -26,14 +28,26 @@ def write_problemlist(problem_dir=None, blacklist=()): for problem in sorted(os.listdir(source_dir)): path = os.path.join(source_dir, problem) if os.path.isfile(path): + force_link = False relpath = os.path.relpath(path, _this_dir) if path.endswith('.tex'): - pname = 'problem%d.tex' % i - i += 1 + if symlink: + pname = 'problem%d.tex' % i + i += 1 + else: + pname = relpath f.write('\\input{%s}\n' % pname) else: # utility file (e.g. image) - pname = problem - os.symlink(relpath, pname) + pname = '.'.join(problem.split('.')[-2:]) + if not symlink: + force_link = True + if symlink or force_link: + if os.path.islink(pname): + ha = hashlib.sha1(open(relpath, 'r').read()).digest() + hb = hashlib.sha1(open(pname, 'r').read()).digest() + assert ha == hb, (relpath, pname) + else: + os.symlink(relpath, pname) f.close() @@ -41,14 +55,13 @@ if __name__ == '__main__': write_problemlist( problem_dir=os.path.join(_this_dir, '..', 'problems'), blacklist=[ - 'Giancoli_6', +# 'Giancoli_6', 'Serway_and_Jewett_4', - 'Serway_and_Jewett_4_venkat', - 'Serway_and_Jewett_4_wking', +# 'Serway_and_Jewett_4_venkat', +# 'Serway_and_Jewett_4_wking', # 'Serway_and_Jewett_8', - 'Thornton_and_Rex_3', - 'Thornton_and_Rex_3_wking', - 'Young_and_Freedman_12', - 'wking', +# 'Thornton_and_Rex_3_wking', +# 'Young_and_Freedman_12', +# 'wking', ] )