add possibility to compile correction
This commit is contained in:
parent
0982a21592
commit
70a1747879
@ -40,10 +40,6 @@ def produce_and_compile(options):
|
|||||||
|
|
||||||
template_file = path(options.template)
|
template_file = path(options.template)
|
||||||
|
|
||||||
if options.output:
|
|
||||||
output = path(options.output)
|
|
||||||
else:
|
|
||||||
# Template should be named tpl_... tpl will replace by the number/name of the version
|
|
||||||
output = path(template_file.dirname()) / path(template_file.name[3:])
|
output = path(template_file.dirname()) / path(template_file.name[3:])
|
||||||
|
|
||||||
if not options.csv_file:
|
if not options.csv_file:
|
||||||
@ -60,8 +56,10 @@ def produce_and_compile(options):
|
|||||||
|
|
||||||
output = output.name
|
output = output.name
|
||||||
|
|
||||||
|
if options.only_corr:
|
||||||
|
options.corr = True
|
||||||
|
else:
|
||||||
tmp_pdf = []
|
tmp_pdf = []
|
||||||
|
|
||||||
for infos in list_infos:
|
for infos in list_infos:
|
||||||
#print("_______" + str(infos))
|
#print("_______" + str(infos))
|
||||||
dest = path(str(infos['num']) + output)
|
dest = path(str(infos['num']) + output)
|
||||||
@ -83,17 +81,37 @@ def produce_and_compile(options):
|
|||||||
print("rm " + " ".join(tmp_pdf))
|
print("rm " + " ".join(tmp_pdf))
|
||||||
os.system("rm " + " ".join(tmp_pdf))
|
os.system("rm " + " ".join(tmp_pdf))
|
||||||
|
|
||||||
|
if options.corr:
|
||||||
|
find_subj_tex_files = "find ./ -iname '[0-9]*_*.tex' "
|
||||||
|
os.system( find_subj_tex_files + " -exec sed -i 's/%\\\\printanswers/\\\\printanswers/g' {} \\;")
|
||||||
|
|
||||||
|
if not options.no_compil:
|
||||||
|
os.system(find_subj_tex_files + " -exec pdflatex {} \\;")
|
||||||
|
os.system( find_subj_tex_files + " -exec sed -i 's/\\\\printanswers/%\\\\printanswers/g' {} \\;")
|
||||||
|
|
||||||
|
if not options.dirty:
|
||||||
|
os.system("rm *.aux *.log")
|
||||||
|
|
||||||
|
if not options.no_join:
|
||||||
|
print(path("./").abspath())
|
||||||
|
print("pdfjam `find ./ -iname '[0-9]*.pdf'` -o corr" + path(output).namebase + ".pdf")
|
||||||
|
os.system("pdfjam `find ./ -iname '[0-9]*.pdf'` -o corr" + path(output).namebase + ".pdf")
|
||||||
|
#os.system("pdfjam *.pdf -o all" + path(output).namebase + ".pdf")
|
||||||
|
print("find ./ -iname '[0-9]*.pdf' -exec rm -f {} \;")
|
||||||
|
os.system("find ./ -iname '[0-9]*.pdf' -exec rm -f {} \;")
|
||||||
|
|
||||||
cwd.cd()
|
cwd.cd()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = optparse.OptionParser()
|
parser = optparse.OptionParser()
|
||||||
parser.add_option("-t","--template",action="store",type="string",dest="template", help="File with the template. The name should have the following form tpl_... .")
|
parser.add_option("-t","--template",action="store",type="string",dest="template", help="File with the template. The name should have the following form tpl_... .")
|
||||||
parser.add_option("-o","--output",action="store",type="string",dest="output",help="Base name for output )")
|
parser.add_option("-C","--csv", action="store", type="string", dest="csv_file", help="Filename of the csv file where informations on subjects are stored")
|
||||||
parser.add_option("-c","--csv", action="store", type="string", dest="csv_file", help="Filename of the csv file where informations are stored")
|
|
||||||
parser.add_option("-N","--number_subjects", action="store",type="int", dest="num_subj", default = 1, help="The number of subjects to make")
|
parser.add_option("-N","--number_subjects", action="store",type="int", dest="num_subj", default = 1, help="The number of subjects to make")
|
||||||
parser.add_option("-d","--dirty", action="store_true", dest="dirty", help="Do not clean after compilation")
|
parser.add_option("-d","--dirty", action="store_true", dest="dirty", help="Do not clean after compilation")
|
||||||
parser.add_option("-n","--no-compile", action="store_true", dest="no_compil", help="Do not compile source code")
|
parser.add_option("-n","--no-compile", action="store_true", dest="no_compil", help="Do not compile source code")
|
||||||
parser.add_option("-j","--no-join", action="store_true", dest="no_join", help="Do not join pdf and clean single pdf")
|
parser.add_option("-j","--no-join", action="store_true", dest="no_join", help="Do not join pdf and clean single pdf")
|
||||||
|
parser.add_option("-o","--only-corr", action="store_true",dest="only_corr", help="Create and compile only correction from existing subjects")
|
||||||
|
parser.add_option("-c","--corr", action="store_true",dest="corr", help="Create and compile correction while making subjects")
|
||||||
|
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
Loading…
Reference in New Issue
Block a user