1 # -*- coding: utf-8 -*-
6 from parseur import FactNode
7 from dictErreurs import jdcSet
10 #-----------------------------------------------------
11 def moveMotCleFromFactToFather(jdc,command,fact,mocle):
12 #-----------------------------------------------------
13 # exemple type : IMPR_GENE
15 if command not in jdcSet : return
17 commands= jdc.root.childNodes[:]
20 if c.name != command:continue
21 for mc in c.childNodes:
22 if mc.name != fact:continue
25 for n in ll.childNodes:
26 if n.name != mocle:continue
27 if debug : print "Changement de place :", n.name, n.lineno, n.colno
28 MonTexte=n.getText(jdc);
30 inseremocle.insereMotCle(jdc,c,MonTexte)
31 logging.info("Changement de place %s ligne %s ",n.name, n.lineno)
33 if boolChange : jdc.reset(jdc.getSource())
34 removemocle.removeMotCleInFact(jdc,command,fact,mocle)
37 #----------------------------------------------------------------------------
38 def moveMotCleFromFactToFactMulti(jdc,oper,factsource,mocle,liste_factcible):
39 #----------------------------------------------------------------------------
40 # exemple type STAT_NON_LINE et RESI_INTER_RELA
41 for factcible in liste_factcible :
42 moveMotCleFromFactToFact(jdc,oper,factsource,mocle,factcible)
43 removemocle.removeMotCleInFact(jdc,oper,factsource,mocle)
46 #----------------------------------------------------------------------------
47 def moveMotCleFromFactToFact(jdc,oper,factsource,mocle,factcible):
48 #----------------------------------------------------------------------------
49 if oper not in jdcSet : return
50 if debug : print "moveMotCleFromFactToFact pour " ,oper,factsource,mocle,factcible
52 commands= jdc.root.childNodes[:]
55 if c.name != oper : continue
57 for mc in c.childNodes:
58 if mc.name != factcible :
64 if debug : print "Pas de changement pour ", oper, " ", factsource, " ",mocle, "cible non trouvée"
67 for mc in c.childNodes:
69 if mc.name != factsource:
75 if debug : print "Pas de changement pour ", oper, " ", factsource, " ",mocle, "source non trouvée"
78 if debug : print "Changement pour ", oper, " ", factsource, " ",mocle, "cible et source trouvées"
79 l=source.childNodes[:]
81 for n in ll.childNodes:
82 if n.name != mocle:continue
83 MonTexte=n.getText(jdc);
84 inseremocle.insereMotCleDansFacteur(jdc,cible,MonTexte)
86 logging.info("Changement de place %s ligne %s vers %s",n.name, n.lineno, cible.name)
87 if boolChange : jdc.reset(jdc.getSource())
92 #------------------------------------------------------
93 def moveMotClefInOperToFact(jdc,oper,mocle,factcible):
94 #------------------------------------------------------
95 # Attention le cas type est THETA_OLD dans calc_G
97 if oper not in jdcSet : return
98 if debug : print "movemocleinoper pour " ,oper,mocle,factcible
100 commands= jdc.root.childNodes[:]
103 if c.name != oper : continue
105 for mc in c.childNodes:
106 if mc.name != factcible :
112 if debug : print "Pas de changement pour ", oper, " ", factcible, " ", "cible non trouvée"
116 for mc in c.childNodes:
123 if debug : print "Pas de changement pour ", oper, " ", mocle, " source non trouvée"
125 MonTexte=source.getText(jdc);
127 inseremocle.insereMotCleDansFacteur(jdc,cible,MonTexte)
128 if boolChange : jdc.reset(jdc.getSource())
129 removemocle.removeMotCle(jdc,oper,mocle)