+
+def lance_eficas_ssIhm_cherche_cr(code=None,fichier=None,ssCode=None,version=None):
+ monEditeur=lance_eficas_ssIhm(code,fichier,ssCode,version)
+ print monEditeur.jdc.cr
+
+def lance_eficas_ssIhm_reecrit(code=None,fichier=None,ssCode=None,version=None,ou=None,cr=False):
+ monEditeur=lance_eficas_ssIhm(code,fichier,ssCode,version)
+ if ou == None :
+ fileName=fichier.split(".")[0]+"_reecrit.comm"
+ fn=fichier.split(".")[0]+"_cr.txt"
+ else :
+ f=fichier.split(".")[0]+"_reecrit.comm"
+ f1=os.path.basename(f)
+ fn=fichier.split(".")[0]+"_cr.txt"
+ f2=os.path.basename(fn)
+ fileName=os.path.join(ou,f1)
+ fileCr=os.path.join(ou,f2)
+ monEditeur.saveFileAs(fileName=fileName)
+ if cr:
+ f = open(fileCr, 'wb')
+ f.write(str(monEditeur.jdc.report()))
+ f.close()
+
+
+def lance_eficas_param(code='Adao',fichier=None,version='V0',macro='ASSIMILATION_STUDY'):
+ """
+ Lance l'appli EFICAS pour trouver les noms des groupes
+ """
+ # Analyse des arguments de la ligne de commande
+ from Editeur import session
+ options=session.parse(sys.argv)
+
+ from qtEficas import Appli
+ app = QApplication(sys.argv)
+ Eficas=Appli(code=code,ssCode=None)
+
+ from ssIhm import QWParentSSIhm
+ parent=QWParentSSIhm(code,Eficas,version)
+
+ import readercata
+ if not hasattr ( Eficas, 'readercata'):
+ monreadercata = readercata.READERCATA( parent, Eficas )
+ Eficas.readercata=monreadercata
+
+ from editor import JDCEditor
+ monEditeur=JDCEditor(Eficas,fichier)
+ texte=loadJDC(fichier)
+ parameters=getJdcParameters(texte,macro)
+ return parameters
+
+def getJdcParameters(jdc,macro):
+ """
+ This function converts the data from the specified macro of the
+ specified jdc text to a python dictionnary whose keys are the
+ names of the data of the macro.
+ """
+ context = {}
+ source = "def args_to_dict(**kwargs): return kwargs \n"
+ source+= "%s = _F = args_to_dict \n"%macro
+ source+= "parameters="+jdc+" \n"
+ source+= "context['parameters'] = parameters \n"
+ code = compile(source, 'file.py', 'exec')
+ eval(code)
+ parameters = context['parameters']
+ return parameters
+
+def loadJDC(filename):
+ """
+ This function loads the text from the specified JdC file. A JdC
+ file is the persistence file of Eficas (*.comm).
+ """
+ fcomm=open(filename,'r')
+ jdc = ""
+ for line in fcomm.readlines():
+ if not (line[0]=='#'):
+ jdc+="%s"%line
+
+ # Warning, we have to make sure that the jdc comes as a simple
+ # string without any extra spaces/newlines
+ return jdc.strip()
+
+if __name__ == "__main__":
+ import sys
+ sys.path.insert(0,os.path.abspath(os.path.join(os.getcwd(),'..')))
+ lance_eficas(code=None,fichier=None,ssCode=None,multi=True)
+
+