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)
# 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
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]()
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'):
# ----------------------------------------------------------------------------------------------------------------------------------
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 :
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]
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):
self.entites = {}
self.mcXSD = []
self.typesXSDDejaDumpes = []
- self.ordre_mc = []
+ self.ordreMC = []
self.lesConditions = "Possible Conditions : "
if debug:
print("___________________________________________________________________")
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)
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")
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)
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()
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
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]
# -----------------
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 = ""
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"):
texteDebutNiveau2 = '<?xml version="1.0" encoding="UTF-8"?>\n<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"\nxmlns="http://chercheurs.edf.com/logiciels/{}"\nxmlns:{}="http://chercheurs.edf.com/logiciels/{}"\nxmlns:{}="http://chercheurs.edf.com/logiciels/{}"\ntargetNamespace="http://chercheurs.edf.com/logiciels/{}"\nelementFormDefault="qualified" attributeFormDefault="unqualified" version="0">\n'
texteDebutNiveau3 = '<?xml version="1.0" encoding="UTF-8"?>\n<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"\nxmlns="http://chercheurs.edf.com/logiciels/{}"\nxmlns:{}="http://chercheurs.edf.com/logiciels/{}"\nxmlns:{}="http://chercheurs.edf.com/logiciels/{}"\nxmlns:{}="http://chercheurs.edf.com/logiciels/{}"\ntargetNamespace="http://chercheurs.edf.com/logiciels/{}"\nelementFormDefault="qualified" attributeFormDefault="unqualified" version="0">\n'
texteFin = "</xs:schema>"
-texteDebut = '<?xml version="1.0" encoding="UTF-8"?>\n<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"\nxmlns="odyssee/cocagne/{}"\nxmlns:{}="odyssee/cocagne/{}"\ntargetNamespace="odyssee/cocagne/{}"\nelementFormDefault="qualified" attributeFormDefault="unqualified" version="0">\n'
+#texteDebut = '<?xml version="1.0" encoding="UTF-8"?>\n<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"\nxmlns="odyssee/cocagne/{}"\nxmlns:{}="odyssee/cocagne/{}"\ntargetNamespace="odyssee/cocagne/{}"\nelementFormDefault="qualified" attributeFormDefault="unqualified" version="0">\n'
# texteAnnotation= '\t<xs:simpleType name="PNEFdico_{}">\n\t\t<xs:annotation>\n\t\t<xs:documentation>{}\n\t\t</xs:documentation>\n\t\t</xs:annotation>\n\t<xs:restriction base="xs:string"></xs:restriction>\n\t</xs:simpleType>\n'