1 # python lib/tools/pdfsingle.py path/to/file.py
2 from os
import chdir
, getcwd
, system
3 from os
.path
import dirname
, basename
, exists
9 def __init__(self
, dir_
):
11 self
.old_dir
= getcwd()
16 def __exit__(self
, exc_type
, exc_val
, exc_tb
):
21 name
= basename(filename
)
22 path
= dirname(filename
)
23 noext
= name
.rsplit('.', 1)[0]
24 test_tmpl
= "tail -n +1 {found} " + \
25 "| sed 's/==> /# ==> /' > tmp.txt ; enscript --font=Courier10 " + \
26 "--continuous-page-numbers --no-header --pretty-print=python " + \
27 "-o - tmp.txt | psnup -2 -P letter -p a4 -m12 | ps2pdf - {name}.pdf ; rm tmp.txt"
28 #"-o - tmp.txt | ps2pdf - {name}.pdf ; rm tmp.txt"
30 with
InsideDir('tests/' + path
):
31 if exists('test_' + name
):
32 found
+= ' lib/tests/%s/test_%s' % (path
, name
)
33 test_cmd
= test_tmpl
.format(name
=noext
, found
=found
)
35 #system('pdfnup --nup 2x1 -o {noext}.pdf {noext}.pdf'.format(noext=noext))