#------------------------------------------- def addpath(x,ajout): if "includegraphics" in x: return x.replace("{",ajout) else: return x # templat= "../tpl.tex" # # Récupérer la liste des textes à introduire # with open("all_texts") as f: lf= f.readlines() # #on récupère le template with open(templat) as f: Ltmpl=f.readlines() # Lall=[] for l in Ltmpl: if "%@@debut" in l: break else: Lall.append(l) bound1= "pagestyle" bound2= "tableofcontents" for l in lf: lok="../"+l.replace("\n","") print(lok) with open(lok) as g: LL=g.readlines() #Z= getlines(LL,"debut","fin") start= False Z= [] for x in LL: if "%@@debut" in x: start= True if "%@@fin" in x: break if start: Z.append(x) # graphiques ajout="{../"+l.split("/")[0]+"/" Lall+=[addpath(x,ajout) for x in Z if not "newcounter" in x] Lall.append("\\eject\n") with open("final.tex","w") as f: for x in Lall[:-1]: f.write(x) f.write("\\tableofcontents\n") f.write("\\end{document}\n")