1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2021 EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 Ce module contient la classe de definition pour les nuplets NUPL
24 from __future__ import absolute_import
26 from builtins import str
32 from Noyau import N_ENTITE,N_MCLIST,N_CR
33 from Ihm import I_ENTITE
34 from Extensions.i18n import tr
35 from . import mcnuplet
37 class NUPL(N_ENTITE.ENTITE,I_ENTITE.ENTITE):
40 class_instance = mcnuplet.MCNUPLET
41 list_instance = N_MCLIST.MCList
45 def __init__(self,fr="",ang="",docu="",statut='f',defaut=None,min=0,max=1,
47 N_ENTITE.ENTITE.__init__(self)
48 I_ENTITE.ENTITE.__init__(self)
56 if self.max =='**' : self.max=float('inf')
57 if self.min =='**' : self.min=float('-inf')
60 # on force le statut des sous entites a obligatoire
61 for e in elements:e.statut='o'
62 self.idracine="NUPLET"
63 self.affecter_parente()
67 Cette methode sert a valider les attributs de l'objet de definition
70 if type(self.min) != int :
71 if self.min != '**' and self.min != float('-inf'):
72 self.cr.fatal(tr("L'attribut 'min' doit etre un entier : ")+str(self.min))
73 if type(self.max) != int :
74 if self.max != '**' and self.max != float('inf'):
75 self.cr.fatal(tr("L'attribut 'max' doit etre un entier : ")+str(self.max))
76 if self.min > self.max :
77 self.cr.fatal(tr("Nombres d'occurrence min et max invalides :") +str(self.min)+","+str(self.max))
78 if type(self.fr) != bytes and type(self.fr) != str :
79 self.cr.fatal(tr("L'attribut 'fr' doit etre une chaine de caracteres"))
80 if self.statut not in ['o','f','c','d']:
81 self.cr.fatal(tr("L'attribut 'statut' doit valoir 'o','f','c' ou 'd'"))
82 if type(self.docu) != bytes and type(self.docu) != str :
83 self.cr.fatal(tr("L'attribut 'docu' doit etre une chaine de caracteres"))
84 self.verifCataRegles()
86 def __call__(self,val,nom,parent):
88 Construit la structure de donnees pour un NUPLET a partir de sa definition (self)
89 de sa valeur (val), de son nom (nom) et de son parent dans l arboresence (parent)
91 if (type(val) == tuple or type(val) == list) and type(val[0]) == tuple:
92 # On est en presence d une liste de nuplets
93 l=self.list_instance()
94 l.init(nom=nom,parent=parent)
96 objet=self.class_instance(nom=nom,definition=self,val=v,parent=parent)
100 # on est en presence d un seul nuplet
101 return self.class_instance(nom=nom,definition=self,val=val,parent=parent)
105 Methode qui cree le rapport de verification du catalogue du nuplet
109 for v in self.entites :
111 cr.debut =tr("Debut ")+v.__class__.__name__+ ' : '
112 cr.fin =tr("Fin ")+v.__class__.__name__+ ' : '
116 def affecter_parente(self):
118 Cette methode a pour fonction de donner un nom et un pere aux
119 sous entites qui n'ont aucun moyen pour atteindre leur parent
121 Il s'agit principalement des mots cles
124 for v in self.entites: