| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- def getlines(L,bound1,bound2):
- ret=[]
- start=False
- for l in L:
- if start:
- if bound2 in l:
- return ret
- else:
- ret.append(l)
- else:
- start = bound1 in l
-
- #-------------------------------------------
- def addpath(x,ajout):
- if "includegraphics" in x:
- return x.replace("{",ajout)
- else:
- return x
- #
- templat= "../tpl.tex"
- # Récupérer le 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 "body" 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,bound1,bound2)
- # 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")
|