35 lignes
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
		
			Fichiers exécutables
		
	
	
	
	
			
		
		
	
	
			35 lignes
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
		
			Fichiers exécutables
		
	
	
	
	
| #!/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]
 | |
|    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"))
 | |
|    
 | |
|    
 | |
| 
 | |
| def clean(nf, suff) :
 | |
|    subprocess.call(["latexmk", "-cd", "-c",  "-jobname="+os.path.splitext(os.path.basename(nf))[0]+suff, nf])
 | |
| 
 | |
| 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 :
 | |
|    compiler(sys.argv[1], suff)
 | |
| 
 | 
