X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=Noyau%2FN_FACT.py;h=c8797c0c8b4ab1793b0a5d1b792ca6ce843d6b17;hb=2c5a8689b9c6cc46804fd268d416d1de2777059e;hp=ef431a752133ce0b366462a96587f02ec18c64a6;hpb=cdd358f4041f957701ac10d86766a85baaef4f78;p=tools%2Feficas.git diff --git a/Noyau/N_FACT.py b/Noyau/N_FACT.py index ef431a75..c8797c0c 100644 --- a/Noyau/N_FACT.py +++ b/Noyau/N_FACT.py @@ -1,25 +1,22 @@ -#@ MODIF N_FACT Noyau DATE 22/03/2011 AUTEUR COURTOIS M.COURTOIS # -*- coding: iso-8859-1 -*- -# RESPONSABLE COURTOIS M.COURTOIS -# CONFIGURATION MANAGEMENT OF EDF VERSION -# ====================================================================== -# COPYRIGHT (C) 1991 - 2011 EDF R&D WWW.CODE-ASTER.ORG -# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY -# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY -# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR -# (AT YOUR OPTION) ANY LATER VERSION. +# Copyright (C) 2007-2013 EDF R&D # -# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT -# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF -# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU -# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE -# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, -# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. -# -# -# ====================================================================== """ Ce module contient la classe de definition FACT @@ -32,18 +29,19 @@ import N_ENTITE import N_MCFACT import N_MCLIST from N__F import _F -from N_types import is_enum +from N_types import is_sequence +from strfunc import ufmt -import N_OBJECT +import N_OBJECT class FACT(N_ENTITE.ENTITE): """ Classe pour definir un mot cle facteur - Cette classe a trois attributs de classe + Cette classe a trois attributs de classe - - class_instance qui indique la classe qui devra etre utilisée - pour créer l'objet qui servira à controler la conformité d'un + - class_instance qui indique la classe qui devra etre utilisée + pour créer l'objet qui servira à controler la conformité d'un mot-clé facteur avec sa définition - list_instance @@ -56,7 +54,7 @@ class FACT(N_ENTITE.ENTITE): def __init__(self,fr="",ang="",docu="",regles=(),statut='f',defaut=None, min=0,max=1,validators=None,**args): - + """ Un mot-clé facteur est caractérisé par les attributs suivants : @@ -89,21 +87,21 @@ class FACT(N_ENTITE.ENTITE): def __call__(self,val,nom,parent): """ - Construit la structure de donnee pour un mot cle facteur a partir - de sa definition (self) de sa valeur (val), de son nom (nom) et de + Construit la structure de donnee pour un mot cle facteur a partir + de sa definition (self) de sa valeur (val), de son nom (nom) et de son parent dans l arboresence (parent) - - Suivant le type de la valeur on retournera soit un objet de type + + Suivant le type de la valeur on retournera soit un objet de type MCFACT soit une liste de type MCLIST. La creation d un mot cle facteur depend de son statut - Si statut ='o' il est obligatoire - - Si statut == 'd' il est facultatif mais ses sous mots cles avec + - Si statut == 'd' il est facultatif mais ses sous mots cles avec defaut sont visibles - - Si statut == 'f' il est facultatif et ses sous mots avec defaut ne + - Si statut == 'f' il est facultatif et ses sous mots avec defaut ne sont pas visibles - Si statut == 'c' il est cache ??? - - Si defaut != None, on utilise cette valeur pour calculer la valeur + - Si defaut != None, on utilise cette valeur pour calculer la valeur par defaut du mot cle facteur """ if val is None: @@ -118,7 +116,7 @@ class FACT(N_ENTITE.ENTITE): # On ne devrait jamais passer par la print "On ne devrait jamais passer par la" return None - elif is_enum(val) and len(val) == 0 and self.statut == 'o': + elif is_sequence(val) and len(val) == 0 and self.statut == 'o': # On est dans le cas où le mcfact est présent mais est une liste/tuple # vide. Il est obligatoire donc on l'initialise. Les règles, mots-clés # obligatoires diront si un mcfact vide est accepté. @@ -127,39 +125,30 @@ class FACT(N_ENTITE.ENTITE): # On cree toujours une liste de mcfact l=self.list_instance() l.init(nom = nom,parent=parent) - if type(val) in (types.TupleType,types.ListType) : + if type(val) in (types.TupleType, types.ListType, self.list_instance) : for v in val: if type(v) == types.DictType or isinstance(v, _F): objet=self.class_instance(nom=nom,definition=self,val=v,parent=parent) l.append(objet) + elif isinstance(v, self.class_instance): + l.append(v) else: l.append(N_OBJECT.ErrorObj(self,v,parent,nom)) elif type(val) == types.DictType or isinstance(val, _F): objet=self.class_instance(nom=nom,definition=self,val=val,parent=parent) l.append(objet) + elif isinstance(val, self.class_instance): + l.append(val) else: l.append(N_OBJECT.ErrorObj(self,val,parent,nom)) return l def verif_cata(self): - if type(self.min) != types.IntType : - if self.min != '**': - self.cr.fatal("L'attribut 'min' doit etre un entier : %s" %`self.min`) - if type(self.max) != types.IntType : - if self.max != '**': - self.cr.fatal("L'attribut 'max' doit etre un entier : %s" %`self.max`) - if self.min > self.max : - self.cr.fatal("Nombres d'occurrence min et max invalides : %s %s" %(`self.min`,`self.max`)) - if type(self.fr) != types.StringType : - self.cr.fatal("L'attribut 'fr' doit etre une chaine de caractères : %s" %`self.fr`) - if type(self.regles) != types.TupleType : - self.cr.fatal("L'attribut 'regles' doit etre un tuple : %s" %`self.regles`) - if self.statut not in ['f','o','c','d'] : - self.cr.fatal("L'attribut 'statut' doit valoir 'o','f','c' ou 'd' : %s" %`self.statut`) - if type(self.docu) != types.StringType : - self.cr.fatal("L'attribut 'docu' doit etre une chaine de caractères : %s" %`self.docu`) - if self.validators and not self.validators.verif_cata(): - self.cr.fatal("Un des validateurs est incorrect. Raison : "+self.validators.cata_info) + self.check_min_max() + self.check_fr() + self.check_regles() + self.check_statut() + self.check_docu() + self.check_validators() self.verif_cata_regles() -