Clean up latex test harness and build all but Serway and Jewett v4.
authorW. Trevor King <wking@drexel.edu>
Thu, 12 Apr 2012 07:50:44 +0000 (03:50 -0400)
committerW. Trevor King <wking@drexel.edu>
Thu, 12 Apr 2012 07:50:44 +0000 (03:50 -0400)
latex/test/Makefile
latex/test/probs.tex
latex/test/sols.tex
latex/test/write_problemlist.py

index 7ed6b117a37ec095c93987a2abe8bb9472689bf6..61b879005ba44578d8339e8630064c769cf1b32f 100644 (file)
@@ -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)
index fa21ac1b22c30c6cac0236460be224412f07e3d3..2e8ed00f9656d17e9495ea082775bef9d11a09af 100644 (file)
@@ -1,4 +1,5 @@
 \documentclass[letterpaper, 10pt]{article}
+\usepackage{etex}
 
 \PassOptionsToPackage{nosolutions}{problempack}
 
index 1596819018e976effe36b74671d1e0d5b2517821..6d56e0733eb2b1c66d0e6da9d4e41ff2bde194d8 100644 (file)
@@ -1,4 +1,5 @@
 \documentclass[letterpaper, 10pt]{article}
+\usepackage{etex}
 
 \PassOptionsToPackage{solutions,loose}{problempack}
 
index 2e3ef27b9cfff61f11564aa11fc499731ca8eda1..fe3fae24afa2f14dc24708c8c9bd325b2145d856 100755 (executable)
@@ -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',
             ]
         )