Salome HOME
version 19 mars
[tools/eficas.git] / Validation / V_ENSEMBLE.py
1 # -*- coding: iso-8859-1 -*-
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
22 class ENSEMBLE:
23    """
24       La règle vérifie que si un mot-clé de self.mcs est present 
25           parmi les elements de args tous les autres doivent etre presents.
26
27       Ces arguments sont transmis à la règle pour validation sous la forme 
28       d'une liste de noms de mots-clés ou d'un dictionnaire dont 
29       les clés sont des noms de mots-clés.
30    """
31    def verif(self,args):
32       """
33           La methode verif effectue la verification specifique à la règle.
34           args peut etre un dictionnaire ou une liste. Les éléments de args
35           sont soit les éléments de la liste soit les clés du dictionnaire.
36       """
37       #  on compte le nombre de mots cles presents, il doit etre egal a la liste
38       #  figurant dans la regle
39       text = ''
40       test = 1
41       args = self.liste_to_dico(args)
42       pivot = None
43       for mc in self.mcs:
44         if args.has_key(mc):
45           pivot = mc
46           break
47       if pivot :
48         for mc in self.mcs:
49           if mc != pivot :
50             if not args.has_key(mc):
51               text = text + "- "+ pivot + u" étant présent, "+mc+ u" doit être présent"+'\n'
52               test = 0
53       return text,test
54
55
56