Salome HOME
Version cmt-01
[tools/eficas.git] / Traducteur / dictErreurs.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013   EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 import logging
22 import sets
23
24 jdcSet=sets.Set()
25
26
27 def EcritErreur(listeGena,ligne=None) :
28     from sys import dict_erreurs
29     maCle=""
30     for Mot in listeGena :
31         maCle=maCle+"_"+Mot
32     #try :
33     if ( 1 == 1) :
34         maClef=maCle[1:]
35         if maClef in dict_erreurs.keys() :
36            if ligne != None :
37               logging.warning("ligne %d : %s ",ligne,dict_erreurs[maClef])
38            else :
39               logging.warning("%s",dict_erreurs[maClef])
40         else :
41            maCle=""
42            for Mot in listeGena[:-1] :
43               maCle=maCle+"_"+Mot
44            maClef=maCle[1:]
45            maClef=maCle+"_"+"VALEUR"
46            if maClef in dict_erreurs.keys() :
47               if ligne != None :
48                   logging.warning("ligne %d : %s ",ligne,dict_erreurs[maClef])
49               else :
50                   logging.warning("%s",dict_erreurs[maClef])
51     #except :
52     #    pass
53
54 def GenereErreurPourCommande(jdc,listeCommande) :
55     commands= jdc.root.childNodes[:]
56     commands.reverse()
57     for c in commands:
58         jdcSet.add(c.name) 
59         for Mot in listeCommande :
60            if c.name != Mot :continue
61            EcritErreur((Mot,),c.lineno)
62
63 def GenereErreurMotCleInFact(jdc,command,fact,mocle):
64     for c in jdc.root.childNodes:
65         if c.name != command:continue
66         for mc in c.childNodes:
67             if mc.name != fact:continue
68             l=mc.childNodes[:]
69             for ll in l:
70                 for n in ll.childNodes:
71                     if n.name != mocle:
72                        continue
73                     else :
74                        EcritErreur((command,fact,mocle,),c.lineno)
75
76 def GenereErreurMCF(jdc,command,fact):
77     for c in jdc.root.childNodes:
78         if c.name != command:continue
79         for mc in c.childNodes:
80             if mc.name != fact:
81                 continue
82             else : 
83                 EcritErreur((command,fact,),c.lineno)
84
85 def GenereErreurValeur(jdc,command,fact,list_valeur):
86     for c in jdc.root.childNodes:
87         if c.name != command:continue
88         for mc in c.childNodes:
89             if mc.name != fact:continue
90             texte=mc.getText(jdc)
91             for valeur in list_valeur:
92                trouve=texte.find(valeur)
93                if trouve > -1 :  
94                   logging.warning("%s doit etre supprimee ou modifiee dans %s : ligne %d",valeur,c.name,mc.lineno)
95
96 def GenereErreurValeurDsMCF(jdc,command,fact,mocle,list_valeur):
97     for c in jdc.root.childNodes:
98         if c.name != command:continue
99         for mc in c.childNodes:
100             if mc.name != fact:continue
101             l=mc.childNodes[:]
102             for ll in l:
103                 for n in ll.childNodes:
104                     if n.name != mocle:continue
105                     texte=n.getText(jdc)
106                     for valeur in list_valeur:
107                         trouve=texte.find(valeur)
108                         if trouve > -1 :  
109                            logging.warning("%s doit etre supprimee ou modifiee dans %s : ligne %d",valeur,c.name,n.lineno)