From: pascale.noyret Date: Thu, 26 Apr 2018 14:34:47 +0000 (+0200) Subject: menage X-Git-Tag: V8_5_0rc2a2~3^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=221219339e96eff072820ce08ca34fd156146eb1;p=modules%2Feficas.git menage --- diff --git a/Efi2Xsd/V0readerEfficas.py b/Efi2Xsd/V0readerEfficas.py deleted file mode 100755 index 922d59e2..00000000 --- a/Efi2Xsd/V0readerEfficas.py +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import sys,os -import raw.efficas as efficas -import types - -sys.path.insert(0,os.path.abspath(os.path.join(os.getcwd(),'..'))) -sys.path.insert(0,os.path.abspath(os.path.join(os.getcwd(),'..','UiQT5'))) - - -from Accas import * - - -# Attention pas d heritage possible (cf doc pyxbe) - -dictSIMPEficasXML= { 'typ' : 'typeAttendu', 'statut' : 'statut', - 'min_occurs': 'min' , 'max_occurs' : 'max', - 'homo' : 'homo' , 'position' : 'portee', - 'validators': 'validators' , 'sug' : 'valeur_sugg', - 'defaut' : 'ValeurDef' , 'into' : ('PlageValeur','into'), - 'val_min' : ('PlageValeur','borne_inf') , 'val_max' : ('PlageValeur','borne_sup'), - 'ang' : ('doc','ang') , 'fr' : ('doc','fr',) , - 'docu' : ('doc','docu'),} - -dictSIMPXMLEficas = {'doc' : {'fr' : 'fr' , 'ang' : 'ang' , 'docu' : 'docu' }, - 'PlageValeur' : {'borne_sup' : 'val_max' , 'into' : 'into' , 'borne_inf' : 'val_min' ,}, - 'statut' : 'statut' , 'validators' : 'validators' , 'homo' : 'homo' , - 'ValeurDef' : 'defaut' , 'min' : 'min_occurs' , - 'valeur_sugg' : 'sug' , 'portee' : 'position' , 'max' : 'max_occurs' , } - - -# ------------------------------ -class monSIMP (efficas.T_SIMP): -# ------------------------------ - - def explore(self): - #print "je passe dans explore pour SIMP ", self.nom - self.dictArgsEficas={} - self.dictArgsEficas['typ']=self.typeAttendu - for nomXMLArg in dir(self) : - if nomXMLArg in dictSIMPXMLEficas.keys() : - nomEficasArg=dictSIMPXMLEficas[nomXMLArg] - argu=getattr(self,nomXMLArg) - if argu==None : continue - if type(nomEficasArg) == types.DictionaryType: - for nomXML in nomEficasArg.keys(): - arguDecoupe=getattr(argu,nomXML) - nomEficasDecoupe=nomEficasArg[nomXML] - self.dictArgsEficas[nomEficasDecoupe]=arguDecoupe - else : - self.dictArgsEficas[nomEficasArg] = argu - - #if argNew != None : print argNew - self.objAccas=A_SIMP.SIMP(**self.dictArgsEficas) - self.objAccas.nom=self.nom - - def getAccasEquivalent(self): - return self.nom, self.objAccas - -# ------------------------------ -class monPROC(efficas.T_PROC): -# ------------------------------ - def explore(self): - #print "je passe dans explore pour PROC ", self.nom - #print self.content() - #print "________________" - self.dictConstruction={} - self.dictConstruction['nom']=self.nom - - for obj in self.content(): - #print obj - if hasattr(obj,'explore') : obj.explore() - if hasattr(obj,'getAccasEquivalent') : - nom,objetAccas=obj.getAccasEquivalent() - self.dictConstruction[nom]=objetAccas - self.dictConstruction['op']=None - self.objAccas=A_PROC.PROC(**self.dictConstruction) - - -# ------------------------------ -class monFACT(efficas.T_FACT): -# ------------------------------ - def explore(self): - #print "je passe dans explore pour FACT ", self.nom - #print self.content() - self.dictConstruction={} - for obj in self.content(): - if hasattr(obj,'explore') : obj.explore() - if hasattr(obj,'creeAccasEquivalent') : - nom,objetAccas=obj.creeAccasEquivalent() - self.dictConstruction[nom]=objetAccas - self.objAccas=A_FACT.FACT(**self.dictConstruction) - - def getAccasEquivalent(self): - return self.nom, self.objAccas - - -# ------------------------------ -class monCata(efficas.T_cata): -# ------------------------------ - def exploreCata(self): - # On positionne le contexte ACCAS - self.JdC = JDC_CATA (code = 'MED', execmodul = None,) - objAExplorer=self.commandes[0] - for obj in objAExplorer.content(): - if hasattr(obj,'explore') : obj.explore() - - - -efficas.T_SIMP._SetSupersedingClass(monSIMP) -efficas.T_FACT._SetSupersedingClass(monFACT) -efficas.T_PROC._SetSupersedingClass(monPROC) -efficas.T_cata._SetSupersedingClass(monCata) - -if __name__ == "__main__": -# print dir(efficas) -# print dir(efficas.T_SIMP) - - - xml = open('Cata_MED_FAM_test.xml').read() - SchemaMed = efficas.CreateFromDocument(xml) - SchemaMed.exploreCata() - - #print dir(efficas.T_SIMP) - #print dir(efficas.T_SIMP) - - #for maCommande in monCata.commandes : - # for monProc in maCommande.PROC: - # for monFact in monProc.FACT: - # for simp in monFact.SIMP: - # simp.creeAccasEquivalent() diff --git a/Efi2Xsd/V1readerEfficas.py b/Efi2Xsd/V1readerEfficas.py deleted file mode 100755 index dac17d72..00000000 --- a/Efi2Xsd/V1readerEfficas.py +++ /dev/null @@ -1,209 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import sys,os -import raw.efficas as efficas -import types - -sys.path.insert(0,os.path.abspath(os.path.join(os.getcwd(),'..'))) - - -from Accas import * - -# traiter le cas des tuples - -# ds l init du SIMP il manque siValide et fenetreIhm - -from mapDesTypes import dictSIMPEficasXML, dictSIMPXMLEficas -from mapDesTypes import dictFACTEficasXML, dictFACTXMLEficas -from mapDesTypes import dictPROCEficasXML, dictPROCXMLEficas -from mapDesTypes import listeParamDeTypeTypeAttendu, listeParamDeTypeStr, dicoPourCast -from mapDesTypes import listeParamEnListeSiMax, listeParamTjsEnListe - - - -# ------------------------------ -class objetDefinitionAccas: -# ------------------------------ - - def argumentXMLToEficas(self): - # --------------------------- - # Attention, pas de validation pour l instant - # il faut verifier la coherence entre les types contenus dans defaut, sug ... et le typeAttendu - # tout cela dans une fonction verifie pas faite -) - - # Recuperation parametres - self.dictArgsEficas={} - for nomXMLArg in dir(self) : - if nomXMLArg in self.dictATraiter : - nomEficasArg=self.dictATraiter[nomXMLArg] - argu=getattr(self,nomXMLArg) - if argu==None : continue - - if type(nomEficasArg) == types.DictionaryType: - for nomXML in list(nomEficasArg.keys()): - arguDecoupe=getattr(argu,nomXML) - nomEficasDecoupe=nomEficasArg[nomXML] - if arguDecoupe == None : continue - self.dictArgsEficas[nomEficasDecoupe]=arguDecoupe - else : - self.dictArgsEficas[nomEficasArg] = argu - - # Cast dans le bon type des parametres si necessaire - if 'min' in list(self.dictArgsEficas.keys()): - self.dictArgsEficas['min']=int(self.dictArgsEficas['min']) - - if 'max' in list(self.dictArgsEficas.keys()): - if self.dictArgsEficas['max']== -1 : self.dictArgsEficas['max']="**" - else : self.dictArgsEficas['max']=int(self.dictArgsEficas['max']) - - for param in list(self.dictArgsEficas.keys()): - if param in listeParamDeTypeStr : - self.dictArgsEficas[param]=unicode(self.dictArgsEficas[param]) - - # En 2.7 a revoir en 3 ? necessaire - self.nomObj=str(self.nom) - - - - - def getAccasEquivalent(self): - # --------------------------- - return self.nomObj, self.objAccas -# - -# --------------------------------------------------------- -class objetComposeDefinitionAccas (objetDefinitionAccas): -# --------------------------------------------------------- - def exploreArbre(self): - # -------------------------- - liste=[] - for obj in self.content(): liste.append(obj) - #liste.reverse() - # PNPNPN essayer de comprendre reverse ou non - - for obj in liste: - if hasattr(obj,'explore') : obj.explore () - if hasattr(obj,'getAccasEquivalent') : - nom,objetAccas=obj.getAccasEquivalent() - self.dictArgsEficas[nom]=objetAccas - -# ---------------------------------------------------- -class monSIMP (efficas.T_SIMP, objetDefinitionAccas): -# ---------------------------------------------------- - - def explore(self): - # -------------------- - # 2 arguments pour ne pas avoir a differencier les appels explore - self.dictATraiter= dictSIMPXMLEficas - self.argumentXMLToEficas() - - self.objAccas=A_SIMP.SIMP(**self.dictArgsEficas) - self.objAccas.nom=self.nomObj - - def argumentXMLToEficas(self): - # ---------------------------- - objetDefinitionAccas.argumentXMLToEficas(self) - self.convertitEnListes() - self.convertitLesTypes() - - def estListe(self): - # --------------- - if hasattr(self,'max') and self.max > 1 : return True - else : return False - - def attendTuple(self): - # ------------------- - return False - - def convertitEnListes(self): - # ------------------------ - # Cas des Tuples non traites - for param in listeParamTjsEnListe : - if param in self.dictArgsEficas : - if not self.attendTuple() : - self.dictArgsEficas[param]=[self.dictArgsEficas[param],] - - if self.estListe() : - for param in listeParamEnListeSiMax: - if param in self.dictArgsEficas : - if not self.attendTuple() : - self.dictArgsEficas[param]=[self.dictArgsEficas[param],] - - def convertitLesTypes(self): - # ------------------------ - # Cas des Tuples non traites - - typeAttendu = self.dictArgsEficas['typ'] - if typeAttendu in list(dicoPourCast.keys()): - for param in listeParamDeTypeTypeAttendu : - if param in list(self.dictArgsEficas.keys()): - castDsLeTypeAttendu=dicoPourCast[typeAttendu] - valeurACaster=self.dictArgsEficas[param].typesimple - if not isinstance(valeurACaster, (list, tuple)) : - val=castDsLeTypeAttendu(valeurACaster) - self.dictArgsEficas[param]=val - else : - liste=[] - for val in valeurACaster : liste.append(castDsLeTypeAttendu(val)) - self.dictArgsEficas[param]=liste - - -# ------------------------------------------------------- -class monFACT(efficas.T_FACT, objetComposeDefinitionAccas): -# ------------------------------------------------------- - def explore(self): - # -------------------- - print "je passe dans explore pour FACT ", self.nom - - self.dictATraiter= dictFACTXMLEficas - self.argumentXMLToEficas() - self.exploreArbre() - self.objAccas=A_FACT.FACT(**self.dictArgsEficas) - - -# --------------------------------------------------------- -class monPROC(efficas.T_PROC, objetComposeDefinitionAccas): -# --------------------------------------------------------- - def explore(self,cata): - # -------------------- - print "je passe dans explore pour PROC ", self.nom - self.dictATraiter= dictPROCXMLEficas - self.argumentXMLToEficas() - self.exploreArbre() - self.dictArgsEficas['op']=None - - self.objAccas=A_PROC.PROC(**self.dictArgsEficas) - setattr(cata, self.nomObj,self.objAccas) - cata.contexteXML[self.nomObj]=self.objAccas - -# ------------------------------ -class monCata(efficas.T_cata): -# ------------------------------ - def exploreCata(self): - # On positionne le contexte ACCAS - self.JdC = JDC_CATA (code = 'MED', execmodul = None,) - self.contexteXML={} - objAExplorer=self.commandes[0] - for obj in objAExplorer.content(): - if hasattr(obj,'explore') : obj.explore(self) - #print dir(self.JdC) - - - def dumpXSD(self): - for etape in self.contexteXML.values() : - etape.dumpXSD() - -efficas.T_SIMP._SetSupersedingClass(monSIMP) -efficas.T_FACT._SetSupersedingClass(monFACT) -efficas.T_PROC._SetSupersedingClass(monPROC) -efficas.T_cata._SetSupersedingClass(monCata) - -if __name__ == "__main__": -# print dir(efficas) -# print dir(efficas.T_SIMP) - - xml = open('cata_test1.xml').read() - SchemaMed = efficas.CreateFromDocument(xml) - SchemaMed.exploreCata() - #SchemaMed.dumpXSD() - diff --git a/Efi2Xsd/mesAgregats.py b/Efi2Xsd/mesAgregats.py deleted file mode 100755 index eb20219c..00000000 --- a/Efi2Xsd/mesAgregats.py +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import sys,os -#import raw.efficas as efficas -import types - -sys.path.insert(0,os.path.abspath(os.path.join(os.getcwd(),'..'))) - - - -class X_MCSIMP: -# ------------- - - def buildObjPyxb(self) : - if not self.cata.modeleMetier : return - #print ('X_MCSIMP buildObjPyxb', self.nom, self) - self.monNomDeClasseModeleMetier='T_'+self.nom - self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomDeClasseModeleMetier) - if self.val != None : self.objPyxb=self.maClasseModeleMetier(self.val) - else : self.objPyxb=self.maClasseModeleMetier() - #print ('fin X_MCSIMP', self.objPyxb, self.nom,self) - - - def setValeurObjPyxb(self,newVal): - if not self.cata.modeleMetier : return - print ('setValeurObjPyxb') - if newVal != None : nvlObj=self.maClasseModeleMetier(newVal) - else : nvlObj=self.maClasseModeleMetier() - self.val=newVal - self.objPyxb=nvlObj - setattr(self.parent.objPyxb, self.nom, nvlObj) - - -class X_MCCOMPO: -# -------------- -# - def buildObjPyxb(self,mc_list) : - if not self.cata.modeleMetier : return - print ('X_MCCOMPO buildObjPyxb', self.nom, self) - self.monNomDeClasseModeleMetier='T_'+self.nom - self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomDeClasseModeleMetier) - listArg=[] - for objAccas in mc_list : - from Accas.A_MCLIST import MCList - if isinstance(objAccas,MCList) : - for mcfact in objAccas : listArg.append(mcfact.objPyxb) - else : listArg.append(objAccas.objPyxb) - print (listArg) - self.objPyxb=self.maClasseModeleMetier(*listArg) - -class X_MCFACT : -# -------------- -# Pour un MCFACT : -# le buildObjPyxb sera pris en charge par X_MCLIST -# on ne fait rien - - def buildObjPyxb(self,mc_list): - #print ('X_MCFACT buildObjPyxb debut et fin', self.nom, self) - pass - -class X_MCLIST: -# -------------- - - - def buildObjPyxb(self,factList): - if not self.cata.modeleMetier : return - #print ('X_MCLIST buildObjPyxb', self.nom, self) - - self.monNomDeClasseModeleMetier='T_'+self.nom - self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomDeClasseModeleMetier) - for objAccas in factList : - listArg=[] - for objAccasFils in objAccas.mc_liste : - listArg.append(objAccasFils.objPyxb) - objAccas.objPyxb=self.maClasseModeleMetier(*listArg) - #print (objAccas , 'ds MCLIST a pour obj pyxb', objAccas.objPyxb) - -class X_JDC: -# ---------- - - def __init__(self): - #print ('X_JDC buildObjPyxb', self) - if not self.cata.modeleMetier : return - self.monNomDeClasseModeleMetier=self.code - self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomDeClasseModeleMetier) - self.objPyxb=self.maClasseModeleMetier() - #print ('fin X_JDC buildObjPyxb', self.objPyxb, self) - - def enregistreEtapePyxb(self,etape): - # OK seulement si sequence (choice ? ...) - print ('ds enregistreEtapePyxb', etape.nom) - if not self.cata.modeleMetier : return - self.objPyxb.append(etape.objPyxb) - #self.toXml() - - def toXml(self): - if not self.cata.modeleMetier : return - print(self.objPyxb.toDOM().toprettyxml()) - print(self.objPyxb.toxml()) - - - -if __name__ == "__main__": - print ('a faire') diff --git a/Efi2Xsd/mesAgregatsDefinition.py b/Efi2Xsd/mesAgregatsDefinition.py deleted file mode 100755 index e05e7be4..00000000 --- a/Efi2Xsd/mesAgregatsDefinition.py +++ /dev/null @@ -1,168 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import sys,os -import types - -#import raw.efficas as efficas -sys.path.insert(0,os.path.abspath(os.path.join(os.getcwd(),'..'))) - -# ds l init du SIMP il manque siValide et fenetreIhm - -from mapDesTypes import dictSIMPEficasXML, dictSIMPXMLEficas -from mapDesTypes import dictFACTEficasXML, dictFACTXMLEficas -from mapDesTypes import dictPROCEficasXML, dictPROCXMLEficas -from mapDesTypes import dictOPEREficasXML, dictOPERXMLEficas -from mapDesTypes import dictBLOCEficasXML, dictBLOCXMLEficas -from mapDesTypes import dictPourCast, dictNomsDesTypes -from mapDesTypes import listeParamDeTypeTypeAttendu, listeParamDeTypeStr, dictPourCast -from mapDesTypes import listeParamTjsSequence, listeParamSelonType - - -from balises import * - -# ----------------- -class X_definition: -# ----------------- - - def getCode(self): - if hasattr(self,'code') : return - obj=self - while ( not hasattr(obj,'code') ): obj=obj.pere - self.code = obj.code - - def genealogie(self): - texte=self.nom - obj=self - while ( hasattr(obj,'pere') ): - texte=obj.pere.nom+'_'+texte - obj=obj.pere - return 'T_'+texte - - def nomSimple(self): - return 'T_'+self.nom - #return self.genealogie() - - - -# ---------------------------------------- -class X_definitionComposee (X_definition): -# ---------------------------------------- - - - def dumpXsd(self): - #print ('------------------------------------------------') - #print ('dumpXsd de ' , self.nom) - - self.getCode() - self.nomDuTypeCree = self.nomSimple() - self.texteSimple = "" # on n ajoute pas de type simple - - self.texteComplexe = debutTypeComplexe.format(self.nomDuTypeCree) - texteComplexeVenantDesFils="" - for nom in self.ordre_mc: - mcFils = self.entites[nom] - mcFils.dumpXsd() - self.texteComplexe += mcFils.texteElt - self.texteSimple += mcFils.texteSimple - texteComplexeVenantDesFils += mcFils.texteComplexe - self.texteComplexe += finTypeComplexe - self.texteComplexe = texteComplexeVenantDesFils + self.texteComplexe - - self.traduitMinMax() - self.texteElt=eltDsSequence.format(self.nom,self.code,self.nomDuTypeCree,self.minOccurs,self.maxOccurs) - - def traduitMinMax(self): - # ____________________ - # valable pour bloc, proc et oper - self.minOccurs = 0 - self.maxOccurs = 1 - -# --------------------------------- -class X_FACT (X_definitionComposee): -#--------- ------------------------ - def traduitMinMax(self): - if self.max == '**' or self.max == float('inf') : self.maxOccurs="unbounded" - else : self.maxOccurs = self.max - self.minOccurs = self.min - if self.statut =='f' : self.minOccurs=0 - -# --------------------------------- -class X_OPER (X_definitionComposee): -# --------------------------------- - pass - -# ---------------------------------- -class X_PROC (X_definitionComposee): -#----------------------------------- - pass - -#----------------------------------- -class X_BLOC (X_definitionComposee): -#----------------------------------- - def dumpXsd(self): - X_definitionComposee.dumpXsd(self) - -#-------------------------------- -class X_SIMP (X_definition): -#-------------------------------- - def dumpXsd(self): - #print ('exploreObjet SIMP') - self.getCode() - - # --> homonymie on peut utiliser genealogie - #self.traduitMinMax() - #self.traduitValMinValMax() - self.nomDuTypeDeBase = self.traduitType() - self.nomDuTypeCree = self.nomSimple() - self.texteSimple = typeSimple.format(self.nomDuTypeCree, self.nomDuTypeDeBase) - self.texteComplexe = "" - - # on se sert des listes si maxOccurs est > 0 - if self.statut =='f' : minOccurs = 0 - else : minOccurs = 1 - self.texteElt = eltDsSequence.format(self.nom,self.code,self.nomDuTypeCree,minOccurs,1) - - - def traduitType(self): - # il faut traduire le min et le max - # il faut ajouter les regles - # il faut gerer les types tuple et fichier - return dictNomsDesTypes[self.type[0]] - - def traduitValMinValMax(self): - self.maxInclusive=self.val_max - self.minInclusive=self.val_min - if self.val_min == float('-inf') and val_max== float('inf') : return - print ('il faut affiner le type du SIMP ', self.nom) - if self.val_max == '**' or self.val_max == float('inf') : self.maxInclusive=None - else : self.maxInclusive = self.val_max - if self.val_min == '**' or self.val_max == float('-inf') : self.maxInclusive=None - else : self.minInclusive = self.val_min - - def traduitMinMax(self): - if self.min == 1 and self.max == 1 : return - print ('il faut creer une liste ' , self.nom) - - -#----------------- -class X_JDC_CATA : -#----------------- - - def dumpXsd(self): - self.texteSimple = "" - self.texteComplexe = "" - self.nomDuTypeCree='T_'+self.code - self.texteCata = debutTypeCata.format(self.nomDuTypeCree) - for commande in self.commandes : - commande.code=self.code - commande.dumpXsd() - self.texteSimple += commande.texteSimple - self.texteSimple += commande.texteComplexe - self.texteCata += commande.texteElt - self.texteCata += finTypeCata - self.texteElt=eltCata.format(self.code, self.nomDuTypeCree) - print (self.texteSimple) - print (self.texteComplexe) - print (self.texteCata) - print (self.texteElt) - diff --git a/Efi2Xsd/readerEfficas.py b/Efi2Xsd/readerEfficas.py deleted file mode 100755 index 5e0112a9..00000000 --- a/Efi2Xsd/readerEfficas.py +++ /dev/null @@ -1,300 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import sys,os -import raw.efficas as efficas -import types - -sys.path.insert(0,os.path.abspath(os.path.join(os.getcwd(),'..'))) - - -from Accas import * - - -# ds l init du SIMP il manque siValide et fenetreIhm - -from mapDesTypes import dictSIMPEficasXML, dictSIMPXMLEficas -from mapDesTypes import dictFACTEficasXML, dictFACTXMLEficas -from mapDesTypes import dictPROCEficasXML, dictPROCXMLEficas -from mapDesTypes import dictOPEREficasXML, dictOPERXMLEficas -from mapDesTypes import dictBLOCEficasXML, dictBLOCXMLEficas -from mapDesTypes import dicoPourCast -from mapDesTypes import listeParamDeTypeTypeAttendu, listeParamDeTypeStr, dicoPourCast -from mapDesTypes import listeParamTjsSequence, listeParamSelonType - - -# ------------------------------ -class objetDefinitionAccas: -# ------------------------------ - - def argumentXMLToEficas(self): - # --------------------------- - # Attention, pas de validation pour l instant - # il faut verifier la coherence entre les types contenus dans defaut, sug ... et le typeAttendu - # tout cela dans une fonction verifie pas faite -) - - # Recuperation parametres - self.dictArgsEficas={} - for nomXMLArg in dir(self) : - if nomXMLArg in self.dictATraiter : - nomEficasArg=self.dictATraiter[nomXMLArg] - argu=getattr(self,nomXMLArg) - if argu==None : continue - - if type(nomEficasArg) == types.DictionaryType: - for nomXML in list(nomEficasArg.keys()): - arguDecoupe=getattr(argu,nomXML) - nomEficasDecoupe=nomEficasArg[nomXML] - if arguDecoupe == None : continue - self.dictArgsEficas[nomEficasDecoupe]=arguDecoupe - else : - self.dictArgsEficas[nomEficasArg] = argu - - # Cast dans le bon type des parametres si necessaire - if 'min' in list(self.dictArgsEficas.keys()): - self.dictArgsEficas['min']=int(self.dictArgsEficas['min']) - - if 'max' in list(self.dictArgsEficas.keys()): - if self.dictArgsEficas['max']== -1 : self.dictArgsEficas['max']="**" - else : self.dictArgsEficas['max']=int(self.dictArgsEficas['max']) - - for param in list(self.dictArgsEficas.keys()): - if param in listeParamDeTypeStr : - self.dictArgsEficas[param]=unicode(self.dictArgsEficas[param]) - - # En 2.7 a revoir en 3 ? necessaire - self.nomObj=str(self.nom) - - def getAccasEquivalent(self): - # --------------------------- - return self.nomObj, self.objAccas -# - -# --------------------------------------------------------- -class objetComposeDefinitionAccas (objetDefinitionAccas): -# --------------------------------------------------------- - def exploreArbre(self,cata): - # -------------------------- - liste=[] - for obj in self.content(): liste.append(obj) - #liste.reverse() - # PNPNPN essayer de comprendre reverse ou non - - for obj in liste: - if hasattr(obj,'explore') : obj.explore(cata) - if hasattr(obj,'getAccasEquivalent') : - nom,objetAccas=obj.getAccasEquivalent() - self.dictArgsEficas[nom]=objetAccas - -# ---------------------------------------------------- -class monSIMP (efficas.T_SIMP, objetDefinitionAccas): -# ---------------------------------------------------- - - def explore(self,cata): - # -------------------- - #print ("je passe dans explore pour SIMP ", self.nom) - self.dictATraiter= dictSIMPXMLEficas - self.argumentXMLToEficas() - - self.objAccas=A_SIMP.SIMP(**self.dictArgsEficas) - self.objAccas.nom=self.nomObj - - def argumentXMLToEficas(self): - # ---------------------------- - #print self.nom - objetDefinitionAccas.argumentXMLToEficas(self) - - if self.attendTuple() : - #nbDElts=type(listeDElt[0]) - print self.nomTypeAttendu - - - self.traiteLesSequences() - print (self.dictArgsEficas) - #self.convertitLesTypes() - - def attendListe(self): - # --------------- - if 'max' in self.dictArgsEficas : - if self.dictArgsEficas['max'] > 1 : return True - if self.dictArgsEficas['max'] == "**" : return True - return False - - def attendTuple(self): - # ----------------- - if self.dictArgsEficas['typ'] != 'tuple' : return False - return True - - def attendTXM(self): - # ---------------- - if self.dictArgsEficas['typ'] == 'TXM' : return True - return False - - - def traiteLesSequences(self): - # --------------------------- - listeDeListe=self.attendListe() - for param in listeParamTjsSequence : - if param in self.dictArgsEficas : - if listeDeListe == False: - listeDElt=self.dictArgsEficas[param][0].content() - listeRetour=self.convertitListeDsLeBonType(listeDElt) - self.dictArgsEficas[param]=listeRetour - else : - listeResultat=[] - # on transforme en liste pour traiter chaque elt de la liste - for i in range(len(self.dictArgsEficas[param])): - if self.dictArgsEficas[param][i].typesimple != None : - lesElts=self.dictArgsEficas[param][i].typesimple - else : - lesElts=self.dictArgsEficas[param][i].content() - if (not(isinstance(lesElts,list)) and not (isinstance(lesElts,tuple))): - lesElts=(lesElts,) - lesEltsTransformes=self.convertitListeDsLeBonType(lesElts) - lesEltsTransformes=self.convertitListeDsLeBonType(lesElts) - listeResultat.append(lesEltsTransformes) - self.dictArgsEficas[param]=listeResultat - #print ('fin de traiteLesSequences pour', self.nom, ' param :', param, 'listeResultat',self.dictArgsEficas[param]) - - - def convertitListeDsLeBonType(self,listeDElt): - # ------------------------------------------- - # Cas des Tuples non traites - typeAttendu = self.dictArgsEficas['typ'] - if typeAttendu in list(dicoPourCast.keys()): - nouvelleListe=[] - castDsLeTypeAttendu=dicoPourCast[typeAttendu] - for valeurACaster in listeDElt : - val=castDsLeTypeAttendu(valeurACaster) - nouvelleListe.append(val) - return nouvelleListe - elif self.attendTuple() : - nbDElts=type(listeDElt[0]).n - - else : return listeDElt - - - - def convertitLesTypes(self): - # ------------------------ - # Cas des Tuples non traites - # Cas des fonctions utilisateurs non traites - - typeAttendu = self.dictArgsEficas['typ'] - if typeAttendu in list(dicoPourCast.keys()): - castDsLeTypeAttendu=dicoPourCast[typeAttendu] - for param in listeParamDeTypeTypeAttendu : - if param in list(self.dictArgsEficas.keys()): - if param in listeParamEnListeSelonType or param in listeParamTjsEnListe : - print ('typeAttendu',typeAttendu) - print (self.dictArgsEficas[param]) - print (self.dictArgsEficas[param].content()) - print (self.dictArgsEficas[param].content()) - return - valeurACaster=self.dictArgsEficas[param].typesimple - if not isinstance(valeurACaster, (list, tuple)) : - val=castDsLeTypeAttendu(valeurACaster) - self.dictArgsEficas[param]=val - else : - liste=[] - for val in valeurACaster : liste.append(castDsLeTypeAttendu(val)) - self.dictArgsEficas[param]=liste - - -# ------------------------------------------------------- -class monFACT(efficas.T_FACT, objetComposeDefinitionAccas): -# ------------------------------------------------------- - def explore(self,cata): - # -------------------- - #print "je passe dans explore pour FACT ", self.nom - - self.dictATraiter= dictFACTXMLEficas - self.argumentXMLToEficas() - self.exploreArbre(cata) - self.objAccas=A_FACT.FACT(**self.dictArgsEficas) - - -# --------------------------------------------------------- -class monPROC(efficas.T_PROC, objetComposeDefinitionAccas): -# --------------------------------------------------------- - def explore(self,cata): - # -------------------- - print "je passe dans explore pour PROC ", self.nom - self.dictATraiter= dictPROCXMLEficas - self.argumentXMLToEficas() - self.exploreArbre(cata) - self.dictArgsEficas['op']=None - - self.objAccas=A_PROC.PROC(**self.dictArgsEficas) - setattr(cata, self.nomObj,self.objAccas) - cata.contexteXML[self.nomObj]=self.objAccas - -# --------------------------------------------------------- -class monOPER(efficas.T_OPER, objetComposeDefinitionAccas): -# --------------------------------------------------------- - def explore(self,cata): -# ------------------------ - print "je passe dans explore pour OPER", self.nom - self.cata=cata - self.dictATraiter= dictOPERXMLEficas - self.argumentXMLToEficas() - self.exploreArbre(cata) - - textCreationClasse='class '+str(self.typeCree)+'(ASSD): pass\n' - exec(textCreationClasse,globals()) - maClasseCreee=globals()[self.typeCree] - self.dictArgsEficas['sd_prod'] = maClasseCreee - cata.contexteXML[self.typeCree] = maClasseCreee - - self.dictArgsEficas['op'] = None - self.objAccas=A_OPER.OPER(**self.dictArgsEficas) - setattr(cata, self.nomObj,self.objAccas) - cata.contexteXML[self.nomObj] = self.objAccas - -# --------------------------------------------------------- -class monBLOC(efficas.T_BLOC, objetComposeDefinitionAccas): -# --------------------------------------------------------- - def explore(self,cata): -# ------------------------ - print ('je passe dans explore pour BLOC', self.nom) - self.cata=cata - self.dictATraiter= dictBLOCXMLEficas - self.argumentXMLToEficas() - self.exploreArbre(cata) - self.objAccas=A_BLOC.BLOC(**self.dictArgsEficas) - setattr(cata, self.nomObj,self.objAccas) - cata.contexteXML[self.nomObj] = self.objAccas - -# ------------------------------ -class monCata(efficas.T_cata): -# ------------------------------ - def exploreCata(self): - # On positionne le contexte ACCAS - self.JdC = JDC_CATA (code = 'MED', execmodul = None,) - self.contexteXML={} - objAExplorer=self.commandes[0] - for obj in objAExplorer.content(): - if hasattr(obj,'explore') : obj.explore(self) - #print dir(self.JdC) - - - def dumpXSD(self): - for etape in self.contexteXML.values() : - etape.dumpXSD() - -efficas.T_SIMP._SetSupersedingClass(monSIMP) -efficas.T_FACT._SetSupersedingClass(monFACT) -efficas.T_PROC._SetSupersedingClass(monPROC) -efficas.T_OPER._SetSupersedingClass(monOPER) -efficas.T_BLOC._SetSupersedingClass(monBLOC) -efficas.T_cata._SetSupersedingClass(monCata) - -if __name__ == "__main__": -# print dir(efficas) -# print dir(efficas.T_SIMP) - - #xml = open('cata_test1.xml').read() - xml = open('cata.xml').read() - SchemaMed = efficas.CreateFromDocument(xml) - SchemaMed.exploreCata() - #SchemaMed.dumpXSD() -