2 # -*- coding: utf-8 -*-
4 import raw.efficas as efficas
7 sys.path.insert(0,os.path.abspath(os.path.join(os.getcwd(),'..')))
8 sys.path.insert(0,os.path.abspath(os.path.join(os.getcwd(),'..','UiQT5')))
14 # Attention pas d heritage possible (cf doc pyxbe)
16 dictSIMPEficasXML= { 'typ' : 'typeAttendu', 'statut' : 'statut',
17 'min_occurs': 'min' , 'max_occurs' : 'max',
18 'homo' : 'homo' , 'position' : 'portee',
19 'validators': 'validators' , 'sug' : 'valeur_sugg',
20 'defaut' : 'ValeurDef' , 'into' : ('PlageValeur','into'),
21 'val_min' : ('PlageValeur','borne_inf') , 'val_max' : ('PlageValeur','borne_sup'),
22 'ang' : ('doc','ang') , 'fr' : ('doc','fr',) ,
23 'docu' : ('doc','docu'),}
25 dictSIMPXMLEficas = {'doc' : {'fr' : 'fr' , 'ang' : 'ang' , 'docu' : 'docu' },
26 'PlageValeur' : {'borne_sup' : 'val_max' , 'into' : 'into' , 'borne_inf' : 'val_min' ,},
27 'statut' : 'statut' , 'validators' : 'validators' , 'homo' : 'homo' ,
28 'ValeurDef' : 'defaut' , 'min' : 'min_occurs' ,
29 'valeur_sugg' : 'sug' , 'portee' : 'position' , 'max' : 'max_occurs' , }
32 # ------------------------------
33 class monSIMP (efficas.T_SIMP):
34 # ------------------------------
37 print "je passe dans explore pour SIMP ", self.nom
38 self.dictArgsEficas={}
39 self.dictArgsEficas['typ']=self.typeAttendu
40 for nomXMLArg in dir(self) :
41 if nomXMLArg in dictSIMPXMLEficas.keys() :
42 nomEficasArg=dictSIMPXMLEficas[nomXMLArg]
43 argu=getattr(self,nomXMLArg)
44 if argu==None : continue
45 if type(nomEficasArg) == types.DictionaryType:
46 for nomXML in nomEficasArg.keys():
47 arguDecoupe=getattr(argu,nomXML)
48 nomEficasDecoupe=nomEficasArg[nomXML]
49 self.dictArgsEficas[nomEficasDecoupe]=arguDecoupe
51 self.dictArgsEficas[nomEficasArg] = argu
53 #if argNew != None : print argNew
54 self.objAccas=A_SIMP.SIMP(**self.dictArgsEficas)
55 self.objAccas.nom=self.nom
57 def getAccasEquivalent(self):
58 return self.nom, self.objAccas
60 # ------------------------------
61 class monPROC(efficas.T_PROC):
62 # ------------------------------
64 print "je passe dans explore pour PROC ", self.nom
65 self.dictConstruction={}
66 self.dictConstruction['nom']=self.nom
68 for obj in self.content():
69 if hasattr(obj,'explore') : obj.explore ()
70 if hasattr(obj,'getAccasEquivalent') :
71 nom,objetAccas=obj.getAccasEquivalent()
72 self.dictConstruction[nom]=objetAccas
73 self.dictConstruction['op']=None
74 self.objAccas=A_PROC.PROC(**self.dictConstruction)
75 print dir(self.objAccas)
76 print self.objAccas.entites
79 # ------------------------------
80 class monFACT(efficas.T_FACT):
81 # ------------------------------
83 #print "je passe dans explore pour FACT ", self.nom
84 self.dictConstruction={}
85 for obj in self.content():
86 if hasattr(obj,'explore') : obj.explore
87 if hasattr(obj,'creeAccasEquivalent') :
88 nom,objetAccas=obj.creeAccasEquivalent()
89 self.dictConstruction[nom]=objetAccas
90 self.objAccas=A_FACT.FACT(**self.dictConstruction)
92 def getAccasEquivalent(self):
93 return self.nom, self.objAccas
96 # ------------------------------
97 class monCata(efficas.T_cata):
98 # ------------------------------
99 def exploreCata(self):
100 # On positionne le contexte ACCAS
101 self.JdC = JDC_CATA (code = 'MED', execmodul = None,)
102 objAExplorer=self.commandes[0]
103 for obj in objAExplorer.content():
104 if hasattr(obj,'explore') : obj.explore()
108 efficas.T_SIMP._SetSupersedingClass(monSIMP)
109 efficas.T_FACT._SetSupersedingClass(monFACT)
110 efficas.T_PROC._SetSupersedingClass(monPROC)
111 efficas.T_cata._SetSupersedingClass(monCata)
113 if __name__ == "__main__":
115 # print dir(efficas.T_SIMP)
118 xml = open('Cata_MED_FAM.xml').read()
119 SchemaMed = efficas.CreateFromDocument(xml)
120 SchemaMed.exploreCata()
122 #print dir(efficas.T_SIMP)
123 #print dir(efficas.T_SIMP)
125 #for maCommande in monCata.commandes :
126 # for monProc in maCommande.PROC:
127 # for monFact in monProc.FACT:
128 # for simp in monFact.SIMP:
129 # simp.creeAccasEquivalent()