]> SALOME platform Git repositories - tools/eficas.git/blob - Efi2Xsd/AccasXsd.py
Salome HOME
fin du menage
[tools/eficas.git] / Efi2Xsd / AccasXsd.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # cette version ne fonctionne pas bien
4
5
6 import sys,os
7 import types
8 import Accas
9 import imp
10 from copy import deepcopy, copy
11 import traceback
12
13
14 # CONTEXT est accessible (__init__.py de Noyau)
15
16 #import raw.efficas as efficas
17 sys.path.insert(0,os.path.abspath(os.path.join(os.getcwd(),'..')))
18
19 # ds l init du SIMP il manque siValide et fenetreIhm
20
21 from .mapDesTypes import dictSIMPEficasXML, dictSIMPXMLEficas
22 from .mapDesTypes import dictFACTEficasXML, dictFACTXMLEficas
23 from .mapDesTypes import dictPROCEficasXML, dictPROCXMLEficas
24 from .mapDesTypes import dictOPEREficasXML, dictOPERXMLEficas
25 from .mapDesTypes import dictBLOCEficasXML, dictBLOCXMLEficas
26 from .mapDesTypes import dictPourCast, dictNomsDesTypes
27 from .mapDesTypes import listeParamDeTypeTypeAttendu, listeParamDeTypeStr, dictPourCast
28 from .mapDesTypes import listeParamTjsSequence, listeParamSelonType
29 from .mapDesTypes import Tuple
30
31 PourTraduction = False
32
33 from .balisesXSD import *
34 # -----------------
35 class X_definition:
36 # -----------------
37
38    def adjoint(self, liste1, liste2):
39        #print ('adjoint', liste1, liste2)
40        l=[]
41        for elt1 in liste1:
42            for elt2 in liste2:
43                newListe=deepcopy(elt1)
44                if  elt2 != []: newListe.append(elt2)
45                l.append(newListe)
46        return l
47
48    def adjointUnMot(self, liste1, mot):
49        l=[]
50        for elt1 in liste1:
51            newListe=deepcopy(elt1)
52            newListe.append(mot)
53            l.append(newListe)
54        return l
55
56    def remplaceListeParContenuEtVide(self, liste1, liste2):
57        listeFinale=[]
58        for elt1 in liste1 :
59          for eltListe in liste2:
60               newListe=deepcopy(elt1)
61               if eltListe!=[] :newListe+=eltListe
62               if newListe not in listeFinale : listeFinale.append(newListe)
63        return listeFinale
64
65    #def remplaceNomListeParContenu(self, liste1, liste2):
66        #print ('remplaceNomListeParContenu', liste1, liste2)
67    #    listeFinale=[]
68    #    for elt1 in liste1 :
69    #      for eltListe in liste2:
70    #           if eltListe == [] : continue
71    #           newListe=deepcopy(elt1)
72    #           if eltListe!=[] :newListe+=eltListe
73    #           listeFinale.append(newListe)
74        #print ('listeFinale', listeFinale)
75    #    return listeFinale
76
77    def fusionne2Listes(self, liste1, liste2):
78        #print ('fusionne2Liste', liste1, liste2)
79        listeFinale=[]
80        for elt1 in liste1 :
81          for eltListe in liste2:
82               newListe=deepcopy(elt1)
83               if eltListe!=[] :newListe.append(eltListe)
84               listeFinale.append(newListe)
85        #print (listeFinale)
86        return listeFinale
87
88    def getNomDuCodeDumpe(self):
89        if hasattr(self,'nomDuCodeDumpe') : return
90        obj=self
91        while ( not hasattr(obj,'nomDuCodeDumpe') ): obj=obj.pere
92        self.nomDuCodeDumpe = obj.nomDuCodeDumpe
93        self.code=obj.code
94        
95    def getXPathComplet(self):
96        obj=self
97        textePath='/'+self.code+":"+self.nom
98        while ( hasattr(obj,'pere') ):
99            obj=obj.pere
100            if isinstance(obj, X_BLOC) : continue 
101            textePath= '/'+ self.code + ":" + obj.nom + textePath
102        textePath='.' + textePath
103        return textePath
104
105    def getXPathSansSelf(self):
106        obj=self
107        textePath=''
108        while ( hasattr(obj,'pere') ):
109            obj=obj.pere
110            if isinstance(obj, X_BLOC) : continue 
111            textePath=  self.code + ":" + obj.nom + '/' + textePath
112        textePath='./'+ self.code + ":" + textePath
113        return textePath
114
115    def getNomCompletAvecBloc(self):
116        obj=self
117        texteNom=self.nom
118        while ( hasattr(obj,'pere') ):
119            texteNom=obj.pere.nom+'_'+texteNom
120            obj=obj.pere
121        return texteNom
122        
123
124    def definitNomDuTypePyxb(self,forceACreer=False):
125        if hasattr(self,'nomDuTypePyxb') : 
126           self.aCreer = False
127           return self.nomDuTypePyxb
128        self.aCreer = True
129        cata = CONTEXT.getCurrentCata() 
130        nom='T_'+self.nom
131        if (hasattr (self, 'nomXML')) and self.nomXML != None : nom='T_'+self.nomXML
132        if not (nom in cata.dictTypesXSD.keys()) :
133           cata.dictTypesXSD[nom] = [self,]
134           self.nomDuTypePyxb=nom
135           return nom
136        self.aCreer = False
137        if nom == 'T_Consigne' : return nom
138        
139        listePossible=cata.dictTypesXSD[nom]
140        indice=0
141        while (indice < len(listePossible)) :
142           objAComparer=listePossible[indice]
143           if self.compare(objAComparer) : 
144              self.nomDuTypePyxb=objAComparer.nomDuTypePyxb
145              return objAComparer.nomDuTypePyxb
146           indice += 1
147        self.aCreer = True
148        cata.dictTypesXSD[nom].append(self)
149        nomAlter='T_'+self.nom+'_'+str(indice)
150        if (hasattr (self, 'nomXML')) and self.nomXML != None : 
151            nomAlter='T_'+self.nomXML+'_'+str(indice)
152        self.nomDuTypePyxb=nomAlter
153        #traceback.print_stack()
154        return nomAlter
155
156
157 # ----------------------------------------
158 class X_compoFactoriseAmbigu(X_definition):
159 # ----------------------------------------
160
161    def __init__(self,nom,listeDeCreation,pere):
162        #print ('__ X_compoFactoriseAmbigu', listeDeCreation)
163        #for (i,index) in listeDeCreation : print i.nom
164        self.label = 'compoAmbigu'
165        self.nom=nom
166        self.pere=pere
167        self.statut='f'
168        self.entites={}
169        self.mcXSD=[]
170        self.ordre_mc=[]
171        self.mcDejaDumpe=set()
172        #print (listeDeCreation)
173        for (mc, index) in listeDeCreation : 
174            self.mcXSD.append(mc)
175            self.ordre_mc.append(mc.nom)
176        #self.mcXSD=list(deepcopy(self.ordre_mc))
177        #for i in self.entites : print (i,self.entites[i])
178        #print ('creation de X_compoFactoriseAmbigu', self.nom, self.mcXSD)
179        self.construitEntites(self.mcXSD)
180        self.constructionArbrePossibles()
181        lesPossibles=deepcopy(self.arbrePossibles)
182       
183        self.getNomDuCodeDumpe()
184        self.nomDuTypePyxb = self.definitNomDuTypePyxb()
185        self.texteSimple = ''
186        self.texteComplexeVenantDesFils = ''
187        self.texteComplexe = debutTypeSubstDsBlocFactorise.format(self.nomDuTypePyxb)
188        # on enleve [] des possibles puisque l elt sera optionnel
189        lesPossibles.remove([])
190        #print ('________________ init de compoAmbigu',self.nom, lesPossibles)
191        #print ('self.entites', self.entites)
192        self.mcXSD=self.factoriseEtCreeDump(lesPossibles,nomAppel='Root')
193        #print ('self.mcXSD',self.mcXSD)
194        self.texteComplexe += finTypeSubstDsBlocFactorise
195        self.texteComplexe +=self.texteComplexeVenantDesFils
196        # PN ?? 12 mai self.texteComplexe=self.texteComplexe+self.texteComplexeVenantDesFils
197        self.label='BlocAmbigu'
198        #print ('fin pour prepareDumpXSD pour', self.nom)
199
200    def compare(self,autreMC):
201        if self.label != autreMC.label : return False
202        if self.arbrePossibles== autreMC.arbrePossible : return True
203        return False
204
205    def construitEntites(self, laListe):
206        for mc in laListe :
207            if mc.nom in self.entites.keys() : self.entites[mc.nom].append(mc)
208            else : self.entites[mc.nom] = [mc,]
209            if mc.label == 'BLOC' or  mc.label == 'BlocAmbigu':
210               self.ajouteLesMCFilsAEntite(mc)
211            
212
213    def ajouteLesMCFilsAEntite(self,blocMc):
214        for mcFilsNom in blocMc.entites.keys():
215          if mcFilsNom not in self.entites.keys(): self.entites[mcFilsNom]=[] 
216          if blocMc.label == 'BlocAmbigu' : 
217            for mc in blocMc.entites[mcFilsNom] : 
218              self.entites[mcFilsNom].append(mc) 
219              if mc.label == 'BLOC' or  mc.label == 'BlocAmbigu':
220                 self.ajouteLesMCFilsAEntite(mc)
221          else :
222            self.entites[mcFilsNom].append(blocMc.entites[mcFilsNom])
223            if blocMc.entites[mcFilsNom].label == 'BLOC' or  blocMc.entites[mcFilsNom].label == 'BlocAmbigu':
224                 self.ajouteLesMCFilsAEntite(blocMc.entites[mcFilsNom])
225            
226
227            
228
229    def constructionArbrePossibles(self):
230        #print ('construction pour FACT ambigu _______________', self.nom)
231        toutesLesLignes=[[]]
232        for child in self.mcXSD :
233           if not hasattr(child, 'arbrePossibles') : child.construitArbrePossibles()
234           if child.label != 'BLOC' :
235               toutesLesLignes = deepcopy(self.fusionne2Listes(toutesLesLignes, child.arbrePossibles))
236           else :
237               toutesLesLignes = deepcopy(self.fusionne2Listes(toutesLesLignes, [child.nom, []]))
238
239        lignesAGarder=[]
240        for ligne in toutesLesLignes:
241            blocContenus=[]
242            aAjouter=True
243            for mc in ligne : 
244                objMC=self.entites[mc][0]
245                if objMC.label == 'BLOC' : 
246                   blocContenus.append(objMC)
247            for b in blocContenus :
248                for frere in blocContenus[blocContenus.index(b)+1:]:
249                    if b.isDisjoint(frere) : continue
250                    aAjouter=False
251                    break
252                if not aAjouter : break
253            if  aAjouter and ligne not in lignesAGarder : 
254                lignesAGarder.append(ligne)
255
256        #print ("______________________________________")
257        #for l in lignesAGarder : print (l)
258        #print (len(lignesAGarder))
259        #print ("______________________________________")
260        self.arbrePossibles=[]
261        for ligne in lignesAGarder :
262            #print ('lignesAGarder', ligne)
263            for newLigne in self.deploye(ligne): 
264                #print (newLigne)
265                if newLigne not in self.arbrePossibles : self.arbrePossibles.append(newLigne)
266        #for l in self.arbrePossibles : print (l)
267        #print ("______________________________________")
268        
269          
270    def deploye (self, ligne):
271        toutesLesLignes=[[]]
272        for mc in ligne :
273            #print ( 'mc in deploye', mc)
274            objMC=self.entites[mc][0]
275            #print ( 'nom', objMC.nom, objMC.label)
276            if objMC.label == 'BLOC' or objMC.label == 'BlocAmbigu': 
277               toutesLesLignes = deepcopy(self.remplaceListeParContenuEtVide(toutesLesLignes, objMC.arbrePossibles))
278            else :
279               toutesLesLignes = deepcopy(self.adjointUnMot(toutesLesLignes,mc ))
280        return toutesLesLignes
281
282    def construitArbrePossibles(self):
283    # inutile car on a deja l arbre mais appele parfois
284        #print ('dans X_factCompoAmbigue ne fait rien', self.nom, self.arbrePossibles)
285        pass
286
287    def dumpXsd(self, dansFactorisation=False, multiple = False, first=False):
288        # on ne fait rien, tout a ete fait dans le init
289        self.texteElt=substDsSequence.format(self.code,self.nomDuTypePyxb,0,1)
290
291    def nomComplet(self) :
292        print ('dans nomComplet pourquoi ?',self, self.nom)
293
294        
295    def factoriseEtCreeDump(self, laListe, indent=2 ,nomAppel=None):
296        #print ('_______________________________ factoriseEtCreeDump')
297        #print(self.nom, laListe, indent, nomAppel)
298        maListeRetour=[]
299        aReduire={}
300
301        if [] in laListe : 
302           declencheChoiceAvecSeqVid=True
303           while [] in laListe : laListe.remove([])
304           #min=0
305        else :
306           declencheChoiceAvecSeqVid=False
307           #min=1
308
309
310        for ligne in laListe :
311           if ligne[0] in aReduire.keys(): 
312              if len(ligne) == 1 :aReduire[ligne[0]].append([])
313              else : aReduire[ligne[0]].append(ligne[1:])
314           else : 
315              if len(ligne) == 1 : aReduire[ligne[0]]=[[]]
316              else : aReduire[ligne[0]]=[ligne[1:],]
317
318        
319        if len(aReduire.keys()) == 1 :
320           if declencheChoiceAvecSeqVid == False : 
321              creeChoice=False
322              creeSequence=True
323              self.texteComplexe += '\t'*(indent) +  debSequenceDsBloc; indent=indent+1
324           else :
325              creeChoice=True
326              creeSequence=False
327              # pour regler le souci du 1er Niveau
328              self.texteComplexe += '\t'*indent + debutChoiceDsBloc; indent=indent+1
329              #if min == 1 : self.texteComplexe += '\t'*indent + debutChoiceDsBloc; indent=indent+1
330              #else        : self.texteComplexe += '\t'*indent + debutChoiceDsBlocAvecMin.format(min); indent=indent+1
331        else :                         
332           #self.texteComplexe += '\t'*indent + debutChoiceDsBlocAvecMin.format(min); indent=indent+1
333           self.texteComplexe += '\t'*indent + debutChoiceDsBloc; indent=indent+1
334           creeChoice=True
335           creeSequence=False
336
337        for nomMC in aReduire.keys():
338            listeSuivante=aReduire[nomMC]
339            if creeChoice and  listeSuivante != [[]] :
340               self.texteComplexe += '\t'*(indent) +  debSequenceDsBloc; indent=indent+1
341            self.ajouteAuxTextes(nomMC,indent)
342            if listeSuivante == [[]] : continue # Est-ce toujours vrai ? 
343            if len(listeSuivante) == 1 : self.ajouteAuxTextes(listeSuivante[0],indent)
344            else : self.factoriseEtCreeDump(listeSuivante, indent+int(creeSequence),nomMC)
345            if creeChoice   : indent=indent -1 ; self.texteComplexe += '\t'*(indent) + finSequenceDsBloc
346
347        if declencheChoiceAvecSeqVid : 
348           self.texteComplexe +=  '\t'*indent +  debSequenceDsBloc
349           self.texteComplexe +=  '\t'*indent + finSequenceDsBloc
350        if creeChoice   : indent=indent -1 ; self.texteComplexe += '\t'*indent + finChoiceDsBloc
351        if creeSequence : indent=indent -1 ; self.texteComplexe += '\t'*(indent) + finSequenceDsBloc
352
353        #if doitFermerSequence : indent=indent-1;self.texteComplexe += '\t'*(indent) + finSequenceDsBloc
354        #print (self.texteSimple)
355        #print ('______',' self.texteComplexe')
356        #print (self.texteComplexe)
357        #print ('_____', 'self.texteComplexeVenantDesFils')
358        #print (self.texteComplexeVenantDesFils)
359        print ('fin pour _______________________________', self.nom)
360        return (maListeRetour)
361        
362        
363    def ajouteAuxTextes(self,nomMC,indent) :
364        #print ('ajouteAuxTextes', nomMC, self.nom, self.entites)
365        #print ('ajouteAuxTextes', nomMC)
366        #for i in self.entites.keys() : print (self.entites[i][0].nom)
367        if (indent  > 3) : indent = indent - 3
368        else : indent = 0
369        if len(self.entites[nomMC]) == 1:
370            mc=self.entites[nomMC][0]
371            mc.dumpXsd(dansFactorisation=True)
372            self.texteComplexe += '\t'*(indent) + mc.texteElt
373            if mc.nomDuTypePyxb not in self.mcDejaDumpe :
374               self.texteComplexeVenantDesFils += mc.texteComplexe
375               self.texteSimple   += mc.texteSimple
376               self.mcDejaDumpe.add(mc.nomDuTypePyxb)
377            return
378
379        leType=type(self.entites[nomMC][0])
380        for e in (self.entites[nomMC][1:]) : 
381           if type(e) != leType:
382              print ('Projection XSD impossible, changez un des ', nomMC)
383              exit()
384
385        
386        # cette boucle ne fonctionne que pour des SIMP
387        resteATraiter=copy(self.entites[nomMC])
388        #print ('________resteATraiter', resteATraiter)
389        listePourUnion=[]
390        first=1
391        while resteATraiter != [] :
392           nvlListeATraiter=[]
393           mc=resteATraiter[0]
394           listePourUnion.append(mc)
395           for autre in resteATraiter[1:]:
396              if not (mc.compare(autre)) :  nvlListeATraiter.append(autre)
397           resteATraiter=copy(nvlListeATraiter)
398
399        if len(listePourUnion) == 1:
400            mc=listePourUnion[0]
401            mc.dumpXsd(dansFactorisation=True,multiple=False,first=first)
402            self.texteComplexe += '\t'*(indent) + mc.texteElt
403            if mc.nomDuTypePyxb not in self.mcDejaDumpe :
404               self.texteComplexeVenantDesFils += mc.texteComplexe
405               self.texteSimple   += mc.texteSimple
406               self.mcDejaDumpe.add(mc.nomDuTypePyxb)
407            return
408              
409        # on ajoute le nom de l element
410        self.entites[nomMC][0].dumpXsd(dansFactorisation=True,multiple=True,first=first)
411        self.texteComplexe += '\t'*(indent) + self.entites[nomMC][0].texteElt
412        texteSimpleUnion=debutSimpleType.format(self.entites[nomMC][0].nomDuTypePyxb)
413        texteSimpleUnion+=debutUnion
414        if len(listePourUnion) == 1 :
415            mc=self.entites[nomMC][0]
416            mc.dumpXsd(dansFactorisation=True,multiple=True,first=first)
417            if mc.nomDuTypePyxb not in self.mcDejaDumpe :
418               self.texteComplexeVenantDesFils += mc.texteComplexe
419               self.texteSimple   += mc.texteSimple
420               self.mcDejaDumpe.add(mc.nomDuTypePyxb)
421        else :
422            for e in listePourUnion :
423                e.dumpXsd(dansFactorisation=True,multiple=True,first=first)
424                if first and (e.nomDuTypePyxb not in self.mcDejaDumpe) :
425                   self.texteComplexeVenantDesFils += e.texteComplexe
426                   self.mcDejaDumpe.add(e.nomDuTypePyxb)
427                   texteSimpleUnion += '\t'*(indent)+e.texteSimple
428                   first=first * 0
429            texteSimpleUnion += finUnion
430        texteSimpleUnion+=fermeSimpleType
431        self.texteSimple   += texteSimpleUnion
432    
433
434
435 # ----------------------------------------
436 class X_definitionComposee (X_definition):
437 # ------------------------------------------
438    
439    def CreeTexteComplexeVenantDesFils(self,dansFactorisation=False):
440        texteComplexeVenantDesFils=""
441        blocsDejaDumpes=set()
442        #for nom in self.ordre_mc:
443        #  mcFils = self.entites[nom]
444        #print (self.nom)
445        for mcFils in self.mcXSD :
446           if not (isinstance(mcFils, Accas.BLOC)) :
447              mcFils.dumpXsd(dansFactorisation)
448              self.texteComplexe += mcFils.texteElt
449              self.texteSimple   += mcFils.texteSimple 
450              texteComplexeVenantDesFils += mcFils.texteComplexe
451              continue
452           else   :
453              #print (mcFils.nom)
454              if hasattr(mcFils,'nomXML')  and mcFils.nomXML in blocsDejaDumpes and mcFils.nomXML != None : continue 
455              if hasattr(mcFils,'nomXML')  and mcFils.nomXML != None: blocsDejaDumpes.add(mcFils.nomXML)
456              mcFils.dumpXsd(dansFactorisation)
457              self.texteComplexe += mcFils.texteElt
458              self.texteSimple   += mcFils.texteSimple 
459              texteComplexeVenantDesFils += mcFils.texteComplexe
460        return texteComplexeVenantDesFils
461
462    def dumpXsd(self, dansFactorisation=False, multiple = False, first=False):
463        #print ('_________ dumpXsd___________', self.nom)
464        if PourTraduction  : print (self.nom)
465        self.prepareDumpXSD()
466  
467        self.getNomDuCodeDumpe()
468        self.nomDuTypePyxb  = self.definitNomDuTypePyxb()
469        self.texteSimple    = "" # on n ajoute pas de type simple
470
471        self.traduitMinMax()
472        # pour accepter les PROC et ...
473        # 
474        if self.aCreer :
475           self.texteComplexe = debutTypeCompo.format(self.nomDuTypePyxb)
476           if isinstance(self,X_OPER) or isinstance(self,X_PROC) : 
477             self.texteComplexe += debutTypeCompoEtape.format(self.code)
478           self.texteComplexe += debutTypeCompoSeq
479           texteComplexeVenantDesFils=self.CreeTexteComplexeVenantDesFils(dansFactorisation)
480           self.texteComplexe  = texteComplexeVenantDesFils + self.texteComplexe
481           # la fin de l oper est traitee dans le dumpXSD de X_OPER
482           if not isinstance(self,X_OPER ) : self.texteComplexe += finTypeCompoSeq
483           if isinstance(self,X_PROC)      : self.texteComplexe += finTypeCompoEtape
484           if not isinstance(self,X_OPER ) : self.texteComplexe += finTypeCompo
485        else :
486           self.texteComplexe = ""
487
488        self.texteElt=eltCompoDsSequence.format(self.nom,self.nomDuCodeDumpe,self.nomDuTypePyxb,self.minOccurs,self.maxOccurs)
489        #print (self.texteComplexe)
490        #print ('------------------------------------------------',self.nom)
491
492    def traduitMinMax(self):
493    # ______________________
494    # valable pour PROC et OPER
495       self.minOccurs = 0
496       self.maxOccurs = 1 
497
498    def compare(self,autreMC):
499        if self.label != autreMC.label : return False
500        if hasattr(self,'nomXML') and hasattr(autreMC,'nomXML') and self.nomXML==autreMC.nomXML and self.nomXML != None : return True
501        for attr in (  'regles', 'fr',  'defaut', 'min' ,'max', 'position' , 'docu' ) :
502            val1=getattr(self,attr)
503            val2=getattr(autreMC,attr)
504            if val1 != val2 : return False
505        for defFille in self.entites.keys():
506            if defFille not in autreMC.entites.keys() : return False
507            if not self.entites[defFille].compare(autreMC.entites[defFille]) : return False
508        return True
509
510    def prepareDumpXSD(self):
511        #print (' ************************ prepareDumpXSD pour', self.nom)
512        self.inUnion=False
513        self.tousLesFils=[]
514        self.mcXSD=[]
515        for nomMC in self.ordre_mc:
516            mc=self.entites[nomMC]
517            self.mcXSD.append(mc)
518            mc.prepareDumpXSD()
519        self.chercheListesDeBlocsNonDisjointsAvecIndex()
520        for l in list(self.listeDesBlocsNonDisjointsAvecIndex) :
521            #print ('je traite ', l, self.besoinDeFactoriserTrivial(l))
522            if not(self.besoinDeFactoriserTrivial(l)) : self.listeDesBlocsNonDisjointsAvecIndex.remove(l)
523            else : self.factorise(l)
524               #print (self.aUnPremierCommunDansLesPossibles(l))
525            #if self.aUnPremierCommunDansLesPossibles(l) :
526            #     print ('aUnCommunDansLesPossibles --> Factorisation')
527            #else : self.listeDesBlocsNonDisjointsAvecIndex.remove(l)
528            # trouver un cas test
529
530    def chercheListesDeBlocsNonDisjointsAvecIndex(self):
531        self.listeDesBlocsNonDisjointsAvecIndex=[]
532        index=-1
533        for nomChild in self.ordre_mc :
534          child=self.entites[nomChild]
535          index=index+1
536          if child.label != 'BLOC' : continue
537          if self.listeDesBlocsNonDisjointsAvecIndex == [] :
538              self.listeDesBlocsNonDisjointsAvecIndex.append([(child,index),])
539              continue
540          vraimentIndependant=True
541          for liste in list(self.listeDesBlocsNonDisjointsAvecIndex):
542              independant=True
543              for (bloc,indInListe) in liste :
544                  if bloc.isDisjoint(child) : continue
545                  if bloc.estLeMemeQue(child) : continue
546                  independant=False
547                  vraimentIndependant=False
548              if not (independant) :
549                  liste.append((child, index))
550          if vraimentIndependant:
551              self.listeDesBlocsNonDisjointsAvecIndex.append([(child,index),])
552        # on nettoye la liste des blocs tous seuls
553        for l in list(self.listeDesBlocsNonDisjointsAvecIndex) :
554            if len(l) ==1 : self.listeDesBlocsNonDisjointsAvecIndex.remove(l)
555
556    def estLeMemeQue(self,autreMC):
557        if hasattr(self,'nomXML') and hasattr(autreMC,'nomXML') and self.nomXML==autreMC.nomXML and self.nomXML != None: return True
558        return False
559
560    def aUnPremierCommunDansLesPossibles(self, laListe) :
561     # fonctionne avec liste de mc ou une liste(mc,index) 
562        import types
563        mesPremiers=set()
564        for elt,index in laListe :
565            if not type(e) == types.ListType :
566               if elt.nom in mesPremiers : return True
567               mesPremiers.add(elt.nom)
568            else :
569               if elt[0].nom in mesPremiers : return True
570               mesPremiers.add(elt[0].nom)
571        return False
572
573    def besoinDeFactoriserTrivial(self,laListe):
574        besoin=False
575        lesPremiers=set()
576        for mcBloc,indice in laListe  :
577           mc=mcBloc.mcXSD[0]
578           if mc.label == 'BLOC': return True
579           if not(mc.statut=='o') : return True
580           if mc.nom in lesPremiers  : return True
581           lesPremiers.add(mc.nom)
582        return False
583
584    def factorise(self,liste):
585        self.listeConstruction=liste
586        indexDebut=liste[0][1]
587        nomDebut=liste[0][0].nom
588        indexFin=liste[-1][1]+1
589        nomFin=liste[-1][0].nom
590        nom=nomDebut+'_'+nomFin
591        listeAFactoriser=[]
592        for  i in range(indexDebut, indexFin) :
593           listeAFactoriser.append((self.mcXSD[i],i))
594
595        newListe=self.mcXSD[0:indexDebut]
596        #print (newListe, newListe.__class__)
597        #print ('je factorise dans -->', self.nom)
598        monEltFacteur=X_compoFactoriseAmbigu(nom,listeAFactoriser,self)
599        newListe.append(monEltFacteur)
600        newListe=newListe+self.mcXSD[indexFin:]
601        self.mcXSD=newListe
602        #print (self.mcXSD)
603        #for i in self.mcXSD : print (i.nom)
604
605    def construitTousLesFils(self):
606        for nomChild in self.ordre_mc :
607          child=self.entites[nomChild]
608          if child.label != 'BLOC' :
609             self.tousLesFils.append(child.nom)
610          else:
611             if child.tousLesFils == [] : child.construitTousLesFils()
612             for nomPetitFils in child.tousLesFils : self.tousLesFils.append(nomPetitFils)
613        #print ('construitArbreEntier pour ', self.nom, self.tousLesFils)
614
615
616    def isDisjoint(self, mc1) :
617        if self.tousLesFils == [] : self.construitTousLesFils()
618        if not (hasattr(mc1, 'tousLesFils')) : mc1.tousLesFils  = []
619        if mc1.tousLesFils  == []  : mc1.construitTousLesFils()
620        for fils in mc1.tousLesFils :
621            if fils in  self.tousLesFils : return False
622        return True
623
624
625
626
627 # ---------------------------------
628 class X_FACT (X_definitionComposee):
629 #--------- ------------------------
630 #Un FACT avec max=** doit se projeter en XSD sous forme d'une sequence a cardinalite 1 et
631 # l'element qui porte la repetition du FACT  
632    def traduitMinMax(self):
633        if self.max     == '**' or self.max  == float('inf') : self.maxOccurs="unbounded"
634        else :                                                 self.maxOccurs = self.max
635        self.minOccurs = self.min
636        if self.statut =='f' : self.minOccurs=0
637
638    def construitArbrePossibles(self):
639        if self.statut   ==  'f' :
640           self.arbrePossibles = (self.nom,[])
641           self.arbreMCPossibles = (self,None)
642        else :
643           self.arbrePossibles = (self.nom,)
644           self.arbreMCPossibles = (self,)
645        #print ('XFACT arbre des possibles de ' ,self.nom, self.arbrePossibles)
646
647
648
649 # ---------------------------------
650 class X_OPER (X_definitionComposee):
651 # ---------------------------------
652    def dumpXsd(self, dansFactorisation=False, multiple = False, first=False):
653        X_definitionComposee.dumpXsd(self,dansFactorisation)
654        self.texteComplexe += finTypeCompoSeq
655        self.texteComplexe += operAttributeName
656        self.texteComplexe += attributeTypeForASSD
657        self.texteComplexe += attributeTypeUtilisateurName.format(self.sd_prod.__name__)
658        self.texteComplexe += finTypeCompoEtape
659        self.texteComplexe += finTypeCompo
660
661
662        cata = CONTEXT.getCurrentCata() 
663        if self.sd_prod.__name__ not in list(cata.dictTypesASSDorUserASSDCrees) :
664           cata.dictTypesASSDorUserASSDCrees[self.sd_prod.__name__]=[self,]
665        else :
666           cata.dictTypesASSDorUserASSDCrees[self.sd_prod.__name__].append(self)
667
668
669 # ----------------------------------
670 class X_PROC (X_definitionComposee):
671 #-----------------------------------
672     pass
673
674 #-----------------------------------
675 class X_BLOC (X_definitionComposee):
676 #-----------------------------------
677    def dumpXsd(self, dansFactorisation=False, multiple = False, first=False):
678        self.tousLesFils=[]
679        
680        self.getNomDuCodeDumpe()
681        # dans ce cas les blocs successifs sont identiques et on ne dumpe que le 1er 
682
683        self.nomDuTypePyxb  = self.definitNomDuTypePyxb()
684        self.texteSimple    = "" # on n ajoute pas de type simple
685
686        # Pour les blocs le minOccurs vaut 0 et le max 1
687        #print ('dumpXsd Bloc', self.nom, self.aCreer)
688        if self.aCreer :
689           self.texteComplexe = debutTypeSubst.format(self.nomDuTypePyxb)
690           texteComplexeVenantDesFils=self.CreeTexteComplexeVenantDesFils(dansFactorisation)
691           self.texteComplexe  = texteComplexeVenantDesFils + self.texteComplexe
692           self.texteComplexe += finTypeSubst
693        else :
694           self.texteComplexe = ""
695
696        self.texteElt=substDsSequence.format(self.code,self.nomDuTypePyxb,0,1)
697
698        #print ('------------------------------------------------')
699
700    def compare(self,autreMC):
701        if self.label != autreMC.label : return False
702        if self.inUnion == True or autreMC.inUnion == True : return False
703        if hasattr(self,'nomXML') and hasattr(autreMC,'nomXML') and self.nomXML==autreMC.nomXML and self.nomXML != None : return True
704        for attr in ( 'condition', 'regles', ):
705            val1=getattr(self,attr)
706            val2=getattr(autreMC,attr)
707            if val1 != val2 : return False
708        for defFille in self.entites.keys():
709            if defFille not in autreMC.entites.keys() : return False
710            if not self.entites[defFille].compare(autreMC.entites[defFille]) : return False
711        return True
712
713    def construitArbrePossibles(self):
714        self.arbrePossibles=[[],]
715        #print ('X_BLOC je construis l arbre des possibles pour ', self.nom)
716        for child in self.mcXSD :
717           if not hasattr(child, 'arbrePossibles') : child.construitArbrePossibles()
718           #print (child.nom, child.label, child.arbrePossibles)
719           if child.label == 'BLOC' : 
720               self.arbrePossibles = deepcopy(self.remplaceListeParContenuEtVide(self.arbrePossibles, child.arbrePossibles))
721           elif child.label == 'BlocAmbigu':
722               #print ("je passe par la pour", self.nom, child.nom, self.arbrePossibles, child.arbrePossibles)
723               self.arbrePossibles = deepcopy(self.remplaceListeParContenuEtVide(self.arbrePossibles, child.arbrePossibles))
724               #print ('resultat', self.arbrePossibles)
725           else :
726               self.arbrePossibles = deepcopy(self.adjoint(self.arbrePossibles, child.arbrePossibles))
727        self.arbrePossibles.append([]) # un bloc n est pas obligatoire
728        #print ('arbre des possibles de ' ,self.nom, self.arbrePossibles)
729
730
731 #--------------------------------
732 class X_SIMP (X_definition):
733 #--------------------------------
734    def dumpXsd(self, dansFactorisation=False, multiple = False, first=False):
735        #print ('_______________' , '*******************', 'je passe la dans dumpXsd SIMP', self.nom, multiple, first)
736        if PourTraduction  : print (self.nom)
737        self.prepareDumpXSD()
738        if multiple : self.inUnion=True
739        #print ('exploreObjet SIMP')
740        self.getNomDuCodeDumpe()
741        self.aCreer = True
742        self.texteComplexe = ""
743        self.texteSimple   = ""
744        self.texteElt      = ""
745        if self.nom =='Consigne' : return
746
747        #  --> homonymie on peut utiliser genealogie ?
748        self.nomDuTypeDeBase = self.traduitType()
749        if not multiple : 
750           self.nomDuTypePyxb   = self.definitNomDuTypePyxb()
751           if first : self.aCreer = True
752        elif first :
753           self.nomDuTypePyxb   = self.definitNomDuTypePyxb(forceACreer=1)
754           self.aCreer = True
755        #else : print ('multiple and not first', self.aCreer)
756
757     
758        
759        # on se sert des listes ou non pour  la gestion des minOccurs /maxOccurs est > 0
760        if self.statut =='f' : minOccurs = 0
761        else                 : minOccurs = 1
762        if dansFactorisation : minOccurs = 1
763
764        #print ('minOccurs',minOccurs)
765        # le defaut est dans l elt Name -> tester la coherence d existence avec Accas
766        # regles Accas
767        if (hasattr (self, 'nomXML')) and self.nomXML != None : nomUtil=self.nomXML
768        else : nomUtil = self.nom
769
770        # pas d elt si on est dans multiple
771        # sauf si on est le '1er'  dans un element ambigu 
772        if not multiple : 
773           #print ('je passe la pas multiple')
774           if self.defaut : 
775              if self.max > 1 or self.max == '**' or self.max ==  float('inf') : 
776                 # a revoir pour les tuples avec defaut
777                 txtDefaut=""
778                 for val in self.defaut : txtDefaut+=str(val) +" "
779                 self.texteElt = eltWithDefautDsSequence.format(nomUtil,self.code,self.nomDuTypePyxb,minOccurs,1,txtDefaut)
780              else :
781                 if str(self.defaut) == 'True' : txtDefaut = 'true'
782                 else : txtDefaut = str(self.defaut)
783                 self.texteElt = eltWithDefautDsSequence.format(nomUtil,self.code,self.nomDuTypePyxb,minOccurs,1,txtDefaut)
784           else : self.texteElt = eltDsSequence.format(nomUtil,self.code,self.nomDuTypePyxb,minOccurs,1)
785        elif first: 
786           self.texteElt = eltDsSequence.format(nomUtil,self.code,self.nomDuTypePyxb,1,1)
787     
788        # self.aCreer est mis a jour ds definitNomDuTypePyxb
789        # ou si elt est le 1er d une liste identique
790        if not self.aCreer : return
791  
792        if not multiple : self.texteSimple  += debutSimpleType.format(self.nomDuTypePyxb)
793        else : self.texteSimple  += debutSimpleTypeSsNom
794        # On est dans une liste
795        if self.max > 1 or self.max == '**' or self.max ==  float('inf') or  hasattr(self.type[0], 'ntuple') : 
796           self.texteSimple  += debutTypeSimpleListe
797           self.texteSimple  += "\t\t\t\t"+debutRestrictionBase.format(self.nomDuTypeDeBase)
798           if self.val_min != float('-inf')  : self.texteSimple += "\t\t\t\t"+minInclusiveBorne.format(self.val_min)
799           if self.val_max != float('inf') and self.val_max != '**' : self.texteSimple +="\t\t\t\t"+ maxInclusiveBorne.format(self.val_max) 
800           if self.into != None:
801              # PN --> traduction des into 
802              into=self.into
803              if self.intoXML != None : into = self.intoXML
804              for val in into : self.texteSimple += "\t\t\t\t"+enumeration.format(val)
805              if PourTraduction  : 
806                 for val in into : print (str(val))
807           self.texteSimple  += fermeBalisesMileu
808           if  self.max !=1 and self.max != '**' and self.max !=  float('inf') : self.texteSimple  += maxLengthTypeSimple.format(self.max)
809           if  self.min !=1 and self.min !=  float('-inf') : self.texteSimple  += minLengthTypeSimple.format(self.min) 
810           self.texteSimple  += fermeRestrictionBase
811        else :
812        # ou pas
813          self.texteSimple  += debutRestrictionBase.format(self.nomDuTypeDeBase)
814          if self.val_min != float('-inf')  : self.texteSimple += minInclusiveBorne.format(self.val_min)
815          if self.val_max != float('inf') and self.val_max != '**' : self.texteSimple += maxInclusiveBorne.format(self.val_max) 
816          if self.into != None:
817             into=self.into
818             if self.intoXML != None : into = self.intoXML
819             for val in into : self.texteSimple += enumeration.format(val)
820             if PourTraduction  : 
821                 for val in into : print (str(val))
822          self.texteSimple  += fermeRestrictionBase
823        self.texteSimple  += fermeSimpleType
824
825
826    def prepareDumpXSD(self):
827        self.inUnion=False
828        if self.statut   ==  'f' :
829           self.arbrePossibles = (self.nom,[])
830        else :
831           self.arbrePossibles = (self.nom,)
832        self.mcXSD=[]
833
834
835
836    def traduitType(self):
837        # il faut traduire le min et le max
838        # il faut ajouter les regles
839        # il faut gerer les types tuple et fichier
840        if hasattr(self.type[0], 'ntuple') : 
841           try :
842              leType=self.validators.typeDesTuples[0]
843              for i in range(self.type[0].ntuple):
844                  if self.validators.typeDesTuples[i] != leType : return ('XXXXXXXX')
845              typeATraduire=leType
846           except : 
847              return ('XXXXXXXX')
848        else : 
849              typeATraduire=self.type[0]
850        if not (typeATraduire in list(dictNomsDesTypes.keys())) :
851           if (isinstance(typeATraduire, Accas.ASSD) or issubclass(typeATraduire, Accas.ASSD)) : 
852              # cas d une creation
853              cata = CONTEXT.getCurrentCata() 
854              if len(self.type) == 2 and self.type[1]=='createObject' : 
855                 if typeATraduire.__name__ not in list(cata.dictTypesASSDorUserASSDCrees) :
856                     cata.dictTypesASSDorUserASSDCrees[typeATraduire.__name__]=[self,]
857                 else :
858                     cata.dictTypesASSDorUserASSDCrees[typeATraduire.__name__].append(self)
859                 return 'xs:string'
860
861              # cas d une consommation
862              if typeATraduire not in list(cata.dictTypesASSDorUserASSDUtilises) :
863                 cata.dictTypesASSDorUserASSDUtilises[typeATraduire]=[self,]
864              else :
865                 cata.dictTypesASSDorUserASSDUtilises[typeATraduire].append(self,)
866              return 'xs:string'
867           else : return ('YYYYY')
868        return dictNomsDesTypes[typeATraduire]
869   
870    def traduitValMinValMax(self):
871        self.maxInclusive=self.val_max
872        self.minInclusive=self.val_min
873        if self.val_min == float('-inf') and val_max== float('inf') : return
874        #print ('il faut affiner le type du SIMP ', self.nom)
875        if self.val_max == '**' or self.val_max == float('inf') : self.maxInclusive=None
876        else : self.maxInclusive = self.val_max
877        if self.val_min == '**' or self.val_max == float('-inf') : self.maxInclusive=None
878        else : self.minInclusive = self.val_min
879        
880    def traduitMinMax(self):
881        if self.min == 1 and self.max == 1 :  return
882        #print ('il faut creer une liste ' , self.nom)
883  
884    def compare(self,autreMC):
885        if self.label != autreMC.label : return False
886        if self.inUnion == True or autreMC.inUnion == True : return False
887        listeAComparer = [ 'type', 'defaut', 'min' ,'max' ,'val_min' , 'val_max' ]
888        if self.intoXML != None : listeAComparer.append('intoXML')
889        else : listeAComparer.append('into')
890        if (hasattr (self, 'nomXML')) and self.nomXML != None : nomUtil=self.nomXML
891        for attr in listeAComparer :
892            val1=getattr(self,attr)
893            val2=getattr(autreMC,attr)
894            if val1 != val2 : return False
895        return True
896
897    def construitArbrePossibles(self):
898        if self.statut   ==  'f' :
899           self.arbrePossibles = (self.nom,[])
900        else :
901           self.arbrePossibles = (self.nom,)
902        #print ('SIMP arbre des possibles de ' ,self.nom, self.arbrePossibles)
903
904
905 #-----------------
906 class X_JDC_CATA :
907 #-----------------
908
909     def dumpXsd(self, avecEltAbstrait,  debug = True):
910         cata = CONTEXT.getCurrentCata() 
911         if debug : print ('avecEltAbstrait   -------------------', avecEltAbstrait)
912
913         if debug : print ('self.importedBy -------------------', self.importedBy)
914         if debug : print ('self.code       -------------------', self.code)
915
916         self.texteSimple   = ""
917         self.texteComplexe = ""
918         self.texteCata     = ""  
919         self.texteDeclaration  = ""
920         self.texteInclusion    = ""
921         self.texteElt          = ""
922         self.texteTypeAbstrait = ""
923
924         if self.implement == "" :
925            self.nomDuCodeDumpe = self.code
926            self.implement      = self.code
927            self.nomDuXsdPere   = self.code
928         else :
929            self.implement,self.nomDuXsdPere=self.implement.split(':')
930            self.nomDuCodeDumpe = self.implement
931
932         if debug : print ('self.implement       -------------------', self.implement)
933         if debug : print ('self.nomDuCodeDumpe   -------------------', self.nomDuCodeDumpe)
934         if debug : print ('self.nomDuXsdPere  -------------------', self.nomDuXsdPere)
935
936         self.nomDuTypePyxb    = 'T_'+self.nomDuCodeDumpe
937         self.dumpLesCommandes()
938
939         if self.implement == self.code :
940            self.texteCata += eltAbstraitCataPPal.format(self.code)
941            self.texteCata += eltCataPPal.format(self.code,self.code,self.code)
942         else :
943            self.texteCata += eltAbstraitCataFils.format(self.implement,self.nomDuXsdPere,self.nomDuXsdPere)
944            self.texteCata += eltCataFils.format(self.implement,self.nomDuXsdPere,self.nomDuXsdPere,self.nomDuXsdPere)
945            self.texteInclusion += includeCata.format(self.nomDuXsdPere)
946
947         self.texteCata += eltCata.format(self.implement,self.implement,self.implement,self.implement,self.nomDuXsdPere)
948         #if self.implement == self.code :
949         #   self.texteCata      += debutTypeCata.format(self.nomDuCodeDumpe)
950         #else :
951         #   self.texteCata      += debutTypeCataExtension.format(self.nomDuCodeDumpe)
952         #   self.texteCata      += debutExtension.format(self.code,self.nomDuCodeDumpe)
953         #   self.texteInclusion += includeCata.format(self.nomDuXsdPere)
954
955
956
957         #for codeHeritant in self.importedBy: 
958         #    self.texteCata += eltCodeSpecDsCata.format(codeHeritant)
959         #    self.texteTypeAbstrait += eltAbstrait.format(codeHeritant,codeHeritant,self.code,codeHeritant)
960
961         #if self.implement != "" : self.texteCata = self.texteCata + finExtension + finTypeCompo
962         #else : self.texteCata  += finTypeCata
963
964         #if self.implement != "" :
965         #   self.texteElt=implementeAbstrait.format(self.nomDuCodeDumpe,self.code,self.nomDuTypePyxb,self.code,self.nomDuCodeDumpe)
966         #else :
967         #   self.texteElt  = eltCata.format(self.nomDuCodeDumpe,self.code, self.nomDuTypePyxb)
968
969         if self.implement == self.code :
970            self.texteXSD  = texteDebut.format(self.code,self.code,self.code,self.code,self.code,self.code)
971         elif self.nomDuXsdPere ==  self.code :
972            self.texteXSD  = texteDebutNiveau2.format(self.code,self.implement,self.code,self.code,self.code, self.code,self.code,self.code,self.code,self.code)
973         else : 
974            self.texteXSD  = texteDebutNiveau3.format(self.code,self.implement,self.code,self.nomDuXsdPere,self.code,self.code,self.code, self.code,self.code,self.code,self.code,self.code)
975
976         if self.texteInclusion != ""   : self.texteXSD += self.texteInclusion
977         self.texteXSD += self.texteSimple
978         self.texteXSD += self.texteComplexe
979
980         #if self.texteTypeAbstrait != "" : self.texteXSD += self.texteTypeAbstrait
981         self.texteXSD += self.texteCata
982         #self.texteXSD += self.texteElt
983        
984         toutesLesKeys=set()
985         texteKeyRef = ""
986         # Pour le nom des key_ref en creation : le type ( une seule key-ref par type. facile a retrouver) 
987         for clef in self.dictTypesASSDorUserASSDCrees:
988             existeASSD=0
989             texteDesFields=""
990             for unOper in self.dictTypesASSDorUserASSDCrees[clef]: 
991                 if  not(isinstance(unOper, Accas.OPER)) : continue
992                 existeASSD=1
993                 texteDesFields+=texteFieldUnitaire.format(self.code, unOper.nom)
994             if existeASSD : texteDesFields=texteDesFields[0:-2]
995             texteDesUserASSD=''
996             existeunUserASSD=0
997             for unSimp in self.dictTypesASSDorUserASSDCrees[clef]: 
998                 if not (isinstance(unSimp, Accas.SIMP)) : continue
999                 texteDesUserASSD += unSimp.getXPathSansSelf() + " | "
1000                 #print (unSimp.getXPathSansSelf())
1001                 #texteFieldUnitaire='/'+self.code+":"+unSimp.nom
1002                 existeunUserASSD=1
1003             if existeunUserASSD:
1004                if existeASSD : texteDesFields = texteDesFields + texteDesUserASSD[0:-2] +"/>\n\t\t"
1005                else: texteDesFields = texteDesUserASSD[0:-2]
1006             print (texteDesUserASSD)
1007             print (texteDesFields)
1008             if texteDesFields != "" :
1009                texteKeyRef  += producingASSDkeyRefDeclaration.format( clef ,texteDesFields) 
1010
1011
1012         # Pour le nom des key-ref en utilisation : la genealogie complete  ( une  key-ref par utilisation et on retrouve facilement la ) 
1013         for clef in self.dictTypesASSDorUserASSDUtilises:
1014             for unSimp in self.dictTypesASSDorUserASSDUtilises[clef]: 
1015                # il faut la genealogie
1016                texteKeyRef  += UsingASSDkeyRefDeclaration.format(unSimp.getNomCompletAvecBloc(), unSimp.type[0].__name__,self.code, unSimp.type[0].__name__,unSimp.getXPathComplet() ) 
1017
1018         #PNPN on debranche les keyref le temps de bien reflechir a leur forme
1019         #if texteKeyRef != '' : 
1020         #   self.texteXSD = self.texteXSD[0:-3]+'>\n'
1021         #   self.texteXSD += texteKeyRef
1022         #   self.texteXSD += fermeEltCata 
1023
1024         self.texteXSD += texteFin
1025
1026
1027
1028         #if not PourTraduction : print (self.texteXSD)
1029         dico = {}
1030         for  k in list(cata.dictTypesXSD.keys()):
1031              if len(cata.dictTypesXSD[k]) > 1:
1032                 index=0
1033                 dico[k]={}
1034                 for definition in cata.dictTypesXSD[k] : 
1035                     nom=definition.nomComplet()
1036                     if index == 0 : dico[k][nom]=k+str(index)
1037                     else :          dico[k][nom]=k+str(index)
1038                     index=index+1
1039   
1040         #import pprint
1041         #if (not PourTraduction) and  (dico != {}) : pprint.pprint(dico)
1042         print ('__________________________ decommenter pour le texteXSD________________________')
1043         print (self.texteXSD)
1044         return self.texteXSD
1045
1046    
1047     def dumpLesCommandes(self):
1048         cata = CONTEXT.getCurrentCata() 
1049         fichierCataSourceExt=os.path.basename(cata.cata.__file__)
1050         fichierCataSource, extension=os.path.splitext(fichierCataSourceExt)
1051         importCataSource=__import__(fichierCataSource,{},{})
1052
1053         texte=""
1054         for m in sys.modules:
1055            monModule=sys.modules[m]
1056            try :
1057               if m in ('os', 'sys', 'inspect', 'six', 'pickle', 'codecs')      : continue
1058               if m in ('cPickle', 'pprint', 'dis', '_sre', 'encodings.aliases'): continue
1059               if m in ('numbers', 'optparse', 'binascii', 'posixpath')         : continue
1060               if m in ('_locale', '_sysconfigdata_nd', 'gc', 'functools')      : continue
1061               if m in ('posixpath', 'types', 'posix', 'prefs')                 : continue
1062               if m in ('warnings', 'types', 'posix', 'prefs')                  : continue
1063               if monModule.__name__[0:15] == '_sysconfigdata_' : continue
1064               if monModule.__name__ == '__future__' :  continue
1065               if monModule.__name__[0:3] == 'Ihm'   :  continue
1066               if monModule.__name__[0:5] == 'numpy' :  continue
1067               if monModule.__name__[0:5] == 'Noyau' :  continue
1068               if monModule.__name__[0:5] == 'Accas' :  continue
1069               if monModule.__name__[0:7] == 'convert'       :  continue
1070               if monModule.__name__[0:7] == 'Efi2Xsd'       :  continue
1071               if monModule.__name__[0:7] == 'Editeur'       :  continue
1072               if monModule.__name__[0:9] == 'generator'     :  continue
1073               if monModule.__name__[0:10] == 'Validation'   :  continue
1074               if monModule.__name__[0:10] == 'Extensions'   :  continue
1075               if monModule.__name__[0:12] == 'InterfaceQT4' :  continue
1076               if monModule.__name__ == fichierCataSource    :  continue
1077               texte= texte + "try : import "+ monModule.__name__ + " \n"
1078               texte= texte + "except : pass \n"
1079               texte= texte + "try : from  "+ monModule.__name__ + ' import * \n'
1080               texte= texte + "except : pass \n"
1081            except :
1082               pass
1083
1084         newModule=imp.new_module('__main__')
1085         exec (texte, newModule.__dict__)
1086         allClassToDump=[]
1087         for i in dir(importCataSource):
1088              if i not in dir(newModule):
1089                 allClassToDump.append(importCataSource.__dict__[i])
1090          
1091
1092         self.texteSimple = ''
1093         self.texteComplexe = ''
1094         for c in allClassToDump :
1095             if not(isinstance(c, Accas.OPER)) and not(isinstance(c, Accas.PROC))  : continue
1096             c.nomDuCodeDumpe=self.nomDuCodeDumpe
1097             c.code=self.implement
1098             c.dumpXsd()
1099             
1100             self.texteSimple   += c.texteSimple
1101             self.texteComplexe += c.texteComplexe
1102             #c.texteElt=eltCompoDsSequenceInExtension.format(c.nom,self.code,c.nomDuTypePyxb)
1103             c.texteElt=eltEtape.format(c.nom,self.implement,c.nomDuTypePyxb,self.implement)
1104             self.texteCata   += c.texteElt