gérer le cas de plusieurs fonctions de même nom
Cette révision appartient à :
@@ -1,16 +1,22 @@
|
||||
import os
|
||||
import os, shutil
|
||||
|
||||
def extraire_caml(nf_tex, nf_ml, nf_texo, tag) :
|
||||
def extraire_caml(nf_tex, mlref, nf_texo, tag) :
|
||||
nf_tex = nf_tex.replace("file://", "")
|
||||
nf_ml = nf_ml.replace("file://", "")
|
||||
nf_ml = os.path.join(os.path.dirname(nf_tex), mlref)
|
||||
nf_texo = nf_texo.replace("file://", "")
|
||||
output_tex = open(nf_texo, "w")
|
||||
output_ml = open(nf_ml, "w")
|
||||
incode = False
|
||||
nomfonc = ""
|
||||
complement = None
|
||||
numfoncAnon = 0
|
||||
mlref = os.path.basename(nf_ml)
|
||||
compteursNoms = {}
|
||||
def setNom(s) :
|
||||
if s not in compteursNoms :
|
||||
compteursNoms[s] = 0
|
||||
return s
|
||||
else :
|
||||
compteursNoms[s] += 1
|
||||
return "{}__{}".format(s, compteursNoms[s])
|
||||
for l in open(nf_tex) :
|
||||
lstrip = l.strip()
|
||||
if lstrip.startswith(r"\begin{"+tag+"}") :
|
||||
@@ -29,9 +35,9 @@ def extraire_caml(nf_tex, nf_ml, nf_texo, tag) :
|
||||
if nomfonc.startswith("rec ") :
|
||||
nomfonc = nomfonc[4:]
|
||||
nomfonc = nomfonc.split()[0]
|
||||
nomfonc = setNom(nomfonc)
|
||||
else :
|
||||
nomfonc = "anon" + str(numfoncAnon)
|
||||
numfoncAnon += 1
|
||||
nomfonc = setNom("anon")
|
||||
output_ml.write("(*** " + nomfonc + " ***)\n")
|
||||
if lstrip == r"\end{"+tag+"}" :
|
||||
output_ml.write("(*** " + nomfonc + "_fin ***)\n\n")
|
||||
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur