From 7b163e079cb575e00cd010b702e0ee5ed02ff2cb Mon Sep 17 00:00:00 2001 From: PASCALE NOYRET Date: Tue, 26 Mar 2024 17:51:08 +0100 Subject: [PATCH] pour la generation XML --- Accas/IO/writer/writer_XML.py | 2 ++ Accas/processing/P_JDC_CATA.py | 4 ++++ Editeur/editor.py | 6 ++--- Editeur/editor_manager.py | 8 +++++++ Editeur/eficas_appli.py | 14 ++++++------ Editeur/eficas_go.py | 20 +++++++++-------- Efi2Xsd/AccasXsd.py | 40 ++++++++++++++++------------------ Efi2Xsd/balisesXSD.py | 2 +- 8 files changed, 55 insertions(+), 41 deletions(-) diff --git a/Accas/IO/writer/writer_XML.py b/Accas/IO/writer/writer_XML.py index 86a2ccae..94fb3265 100644 --- a/Accas/IO/writer/writer_XML.py +++ b/Accas/IO/writer/writer_XML.py @@ -55,8 +55,10 @@ class XMLGenerator(PythonGenerator): self, obj, format="brut", config=None, appliEficas=None, uniteAsAttribut=False ): # try : + print ('Attention changement try en if') if 1: self.texteXML = obj.toXml() + print (obj.toXml) # except : # self.texteXML='Erreur a la generation du fichier XML' # print (self.texteXML) diff --git a/Accas/processing/P_JDC_CATA.py b/Accas/processing/P_JDC_CATA.py index 62d84cc3..f4bc0bf0 100644 --- a/Accas/processing/P_JDC_CATA.py +++ b/Accas/processing/P_JDC_CATA.py @@ -75,6 +75,10 @@ class JDC_CATA(P_ENTITE.ENTITE): # courant à None CONTEXT.unsetCurrentCata() CONTEXT.setCurrentCata(self) + #PN to do verifier pourquoi on y passe 2 fois + #print ('jjjjjjjjjjjjjjjjjjjjjjjjjjjjjuuuuuuuuuuuuuuuuuuuuuuuuuuuuuj', self) + #import traceback + #traceback.print_stack() self.fenetreIhm = None self.definitUserASSD = False self.definitUserASSDMultiple = False diff --git a/Editeur/editor.py b/Editeur/editor.py index b91f07ce..80e8df08 100755 --- a/Editeur/editor.py +++ b/Editeur/editor.py @@ -94,9 +94,9 @@ class Editor: if "xml" in writer.plugins.keys(): self.XMLWriter = writer.plugins["xml"]() else : self.XMLWriter = None - if "python" in writer.plugins.keys(): - self.XMLWriter = writer.plugins["python"]() - else : self.XMLWriter = None + #if "python" in writer.plugins.keys(): + # self.XMLWriter = writer.plugins["python"]() + #else : self.XMLWriter = None if self.formatFichierOut in writer.plugins.keys(): self.myWriter = writer.plugins[self.formatFichierOut]() diff --git a/Editeur/editor_manager.py b/Editeur/editor_manager.py index 142313e2..f1383391 100644 --- a/Editeur/editor_manager.py +++ b/Editeur/editor_manager.py @@ -60,6 +60,14 @@ class EditorManager(object): print ('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') return None + # --------------------------------------------------------------------------------------------------------- + def getEditorForXSDGeneration(self, cataFile=None, dataSetFile=None, formatIn ='python', formatOut = 'xml'): + # --------------------------------------------------------------------------------------------------------- + from Editeur.editor import Editor + editor = Editor(self.appliEficas, cataFile=cataFile, dataSetFile=dataSetFile, formatIn=formatIn, formatOut=formatOut) + return editor + + # --------------------------------------------------------------------------------------------------------------------------------- def getTUIEditor(self,cId = None, cataFile = None, dataSetFile=None, jdc=None, include=0, formatIn ='python', formatOut = 'python'): # ---------------------------------------------------------------------------------------------------------------------------------- diff --git a/Editeur/eficas_appli.py b/Editeur/eficas_appli.py index ecfb3268..e727c017 100755 --- a/Editeur/eficas_appli.py +++ b/Editeur/eficas_appli.py @@ -157,19 +157,19 @@ class EficasAppli: texte = p.convert("execnoparseur") return texte - #------------------------------------------------------ - def getEditor(self, fichier=None, jdc=None, include=0): - #------------------------------------------------------ - #PN reflechir a ce que cela veut dire d avoir plusieurs editeurs - # en TUI + #---------------------------------------------------------------------------------------------------------- + def getEditorForXSDGeneration(self, cataFile=None, datasetFile=None, formatIn='python', formatOut='python'): + #----------------------------------------------------------------------------------------------------------- if (hasattr(self, "editor")) and self.editor != None: print("un seul editeur par application eficas_appli sans Ihm ? ") - # sys.exit() - self.editor = self.editorManager.getEditor(fichier, jdc, include) + sys.exit() + self.editor = self.editorManager.getEditorForXSDGeneration(cataFile, datasetFile, formatIn, formatOut) return self.editor #------------------------------------------------------------------------------------------------------------------- def getWebEditor(self, cId, cataFile = None, datasetFile=None, jdc=None, include=0, formatIn='python', formatOut='python'): + # TO DO : separer proprement TUI et WEB. bien reflechir au ligne + # avant : refaire l API qu on veut en TUI #------------------------------------------------------------------------------------------------------------------- debug = 0 if debug : diff --git a/Editeur/eficas_go.py b/Editeur/eficas_go.py index 17c598b3..525db35d 100755 --- a/Editeur/eficas_go.py +++ b/Editeur/eficas_go.py @@ -102,7 +102,7 @@ def genereXSD(code=None): monEficas = getEficas(code=options.code) monEficas.genereXSD = True - monEditor = monEficas.getEditor() + monEditor = monEficas.getEditorForXSDGeneration(cataFile= options.cataFile) texteXSD = monEditor.dumpXsd(avecEltAbstrait=options.avecEltAbstrait) cataFileTrunc = os.path.splitext(os.path.basename(options.cataFile))[0] @@ -132,21 +132,23 @@ def genereXML(code=None): print("comm file is needed") return - monEficas = getEficas(code=options.code, forceXML=True) - - from .editorSsIhm import JDCEditorSsIhm - - monEditeur = JDCEditorSsIhm(monEficasSsIhm, fichier) + monEficas = getEficas(code=options.code) + monEficas.genereXSD=False + monEficas.withXSD=True + monEditor = monEficas.getEditorForXSDGeneration(cataFile= options.cataFile,datasetFile=fichier,formatOut = 'xml') if options.fichierXMLOut == None: fichierXMLOut = fichier[: fichier.rfind(".")] + ".xml" else: fichierXMLOut = options.fichierXMLOut - if not (monEditeur.jdc.isValid()): + print (monEditor) + print (monEditor.jdc) + if not (monEditor.jdc.isValid()): print("Fichier comm is not valid") return # print ('Fichier comm is not valid') - monEditeur.XMLgenerator.gener(monEditeur.jdc) - monEditeur.XMLgenerator.writeDefault(fichierXMLOut) + monEditor.XMLWriter.gener(monEditor.jdc) + print (monEditor.XMLWriter) + monEditor.XMLWriter.writeDefault(fichierXMLOut) def genereStructure(code=None): diff --git a/Efi2Xsd/AccasXsd.py b/Efi2Xsd/AccasXsd.py index 87f2be05..954d4249 100755 --- a/Efi2Xsd/AccasXsd.py +++ b/Efi2Xsd/AccasXsd.py @@ -352,7 +352,7 @@ class X_compoFactoriseAmbigu(X_definition): self.entites = {} self.mcXSD = [] self.typesXSDDejaDumpes = [] - self.ordre_mc = [] + self.ordreMC = [] self.lesConditions = "Possible Conditions : " if debug: print("___________________________________________________________________") @@ -365,14 +365,14 @@ class X_compoFactoriseAmbigu(X_definition): if hasattr(pere, "listeDesCompoAmbigus"): pere.listeDesCompoAmbigus.append(self) else: - pere.listeDesCompoAmbigus = (self,) + pere.listeDesCompoAmbigus = [self,] doitReecrireLesTypes = False for mc in listeDeCreation: if hasattr(mc, "condition"): self.lesConditions += "\n\t\t\t\t\t\t" + mc.condition doitReecrireLesTypes += mc.possedeDejaUnMCFactorise self.mcXSD.append(mc) - self.ordre_mc.append(mc.nom) + self.ordreMC.append(mc.nom) # if self.nom == 'B1_B2' : debug = True if debug and doitReecrireLesTypes: print("je dois reecrire pour", self.nom) @@ -381,7 +381,7 @@ class X_compoFactoriseAmbigu(X_definition): if debug: print("self.mcXSD", self.mcXSD) if debug: - print("self.ordre_mc", self.ordre_mc) + print("self.ordreMC", self.ordreMC) self.construitEntites(self.mcXSD, debug=debug) if debug: print("apres de self.construitEntites") @@ -1191,7 +1191,7 @@ class X_definitionComposee(X_definition): def creeTexteComplexeVenantDesFils(self, dansFactorisation=False, debug=False): texteComplexeVenantDesFils = "" blocsDejaDumpes = set() - # for nom in self.ordre_mc: + # for nom in self.ordreMC: # mcFils = self.entites[nom] if debug: print("___________________ creeTexteComplexeVenantDesFils", self.nom) @@ -1367,7 +1367,7 @@ class X_definitionComposee(X_definition): self.inUnion = False self.tousLesFils = [] self.mcXSD = [] - for nomMC in self.ordre_mc: + for nomMC in self.ordreMC: mc = self.entites[nomMC] self.mcXSD.append(mc) mc.prepareDumpXSD() @@ -1381,7 +1381,7 @@ class X_definitionComposee(X_definition): def chercheListesDeBlocsNonDisjoints(self): self.listeDesBlocsNonDisjoints = [] - for nomChild in self.ordre_mc: + for nomChild in self.ordreMC: child = self.entites[nomChild] if child.label != "BLOC": continue @@ -1473,7 +1473,7 @@ class X_definitionComposee(X_definition): print("___________ fin fin factorise", nom) def construitTousLesFils(self): - for nomChild in self.ordre_mc: + for nomChild in self.ordreMC: if nomChild == "Consigne" or nomChild == "blocConsigne": continue child = self.entites[nomChild] @@ -2277,18 +2277,19 @@ class X_SIMP(X_definition): # ----------------- class X_JDC_CATA: - # ----------------- +# ----------------- def dumpXsd(self, avecEltAbstrait, avecSubstitution=True, debug=False): + CONTEXT.unsetCurrentCata() + CONTEXT.setCurrentCata(self) cata = CONTEXT.getCurrentCata() + #PN : on essaye de s affranchir du contexte + cata=self # cata.unitAsAttribute = unitAsAttribute cata.unitAsAttribute = True - if debug: - print("avecEltAbstrait -------------------", avecEltAbstrait) - if debug: - print("self.importedBy -------------------", self.importedBy) - if debug: - print("self.code -------------------", self.code) + if debug: print("avecEltAbstrait -------------------", avecEltAbstrait) + if debug: print("self.importedBy -------------------", self.importedBy) + if debug: print("self.code -------------------", self.code) self.texteSimple = "" self.texteComplexe = "" @@ -2306,12 +2307,9 @@ class X_JDC_CATA: self.implement, self.nomDuXsdPere = self.implement.split(":") self.nomDuCodeDumpe = self.implement - if debug: - print("self.implement -------------------", self.implement) - if debug: - print("self.nomDuCodeDumpe -------------------", self.nomDuCodeDumpe) - if debug: - print("self.nomDuXsdPere -------------------", self.nomDuXsdPere) + if debug: print("self.implement -------------------", self.implement) + if debug: print("self.nomDuCodeDumpe -------------------", self.nomDuCodeDumpe) + if debug: print("self.nomDuXsdPere -------------------", self.nomDuXsdPere) self.nomDuTypePyxb = "T_" + self.nomDuCodeDumpe if hasattr(self.cata, "dElementsRecursifs"): diff --git a/Efi2Xsd/balisesXSD.py b/Efi2Xsd/balisesXSD.py index 9b1d02f5..306436bd 100644 --- a/Efi2Xsd/balisesXSD.py +++ b/Efi2Xsd/balisesXSD.py @@ -2,7 +2,7 @@ texteDebut = '\n\n\n' texteDebutNiveau3 = '\n\n' texteFin = "" -texteDebut = '\n\n' +#texteDebut = '\n\n' # texteAnnotation= '\t\n\t\t\n\t\t{}\n\t\t\n\t\t\n\t\n\t\n' -- 2.39.2