| 
									
										
										
										
											2018-02-21 19:12:43 +01:00
										 |  |  | #!/usr/bin/env python3 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import subprocess | 
					
						
							|  |  |  | import sys | 
					
						
							|  |  |  | import os | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def compiler(nf, suff) : | 
					
						
							|  |  |  |    basedir = os.path.dirname(nf) | 
					
						
							|  |  |  |    builddir = os.path.join(basedir, "_build") | 
					
						
							|  |  |  |    basejobname = os.path.splitext(os.path.basename(nf))[0] | 
					
						
							| 
									
										
										
										
											2018-08-05 18:52:08 +02:00
										 |  |  |    options = suff[1] | 
					
						
							|  |  |  |    subprocess.call('''latexmk -pdflua -shell-escape -bibtex-cond -cd -interaction=batchmode -dvi- -jobname=''' +basejobname+suff[0] +''' -outdir=''' + builddir + ''' -latexoption="--output-directory='''+builddir+''' --synctex=0 ''' + options + '''" ''' + nf, shell=True) | 
					
						
							|  |  |  |    os.rename(os.path.join(builddir, basejobname+suff[0]+".pdf"), os.path.join(basedir, basejobname+suff[0]+".pdf")) | 
					
						
							| 
									
										
										
										
											2018-02-21 19:12:43 +01:00
										 |  |  |     | 
					
						
							|  |  |  |     | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def clean(nf, suff) : | 
					
						
							|  |  |  |    subprocess.call(["latexmk", "-cd", "-c",  "-jobname="+os.path.splitext(os.path.basename(nf))[0]+suff, nf]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-05 18:52:08 +02:00
										 |  |  | with open(sys.argv[1]) as f : | 
					
						
							|  |  |  |    for l in f.readlines() : | 
					
						
							|  |  |  |       if l.strip() == "" or l.strip().startswith("%") : | 
					
						
							|  |  |  |          continue | 
					
						
							|  |  |  |       if "beamerarticle" in l or "-PRES" in l or "-PRINT" in l : | 
					
						
							|  |  |  |          modes = [("-PRES", ""), ("-PRINT", "")] | 
					
						
							|  |  |  |       elif "beamer" in l : | 
					
						
							|  |  |  |          modes = [("", "")] | 
					
						
							|  |  |  |       else : | 
					
						
							|  |  |  |          modes = [("-ENONCE", ""), ("-PROF", ""), ("-CORRIGE", "")] | 
					
						
							|  |  |  |       break | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | for suff in modes : | 
					
						
							| 
									
										
										
										
											2018-02-21 19:12:43 +01:00
										 |  |  |    compiler(sys.argv[1], suff) | 
					
						
							|  |  |  | 
 |