1 # -*- coding: utf-8 -*-
2 # CONFIGURATION MANAGEMENT OF EDF VERSION
3 # ======================================================================
4 # COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG
5 # THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
6 # IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY
7 # THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR
8 # (AT YOUR OPTION) ANY LATER VERSION.
10 # THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
11 # WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
12 # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
13 # GENERAL PUBLIC LICENSE FOR MORE DETAILS.
15 # YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE
16 # ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,
17 # 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.
20 # ======================================================================
22 from I_ASSD import ASSD
25 def __init__(self,etape=None,sd=None,reg='oui'):
27 self.jdc.register_fonction(self)
29 def get_formule(self):
31 Retourne une formule décrivant self sous la forme d'un tuple :
32 (nom,type_retourne,arguments,corps)
34 if hasattr(self.etape,'get_formule'):
35 # on est dans le cas d'une formule Aster
36 return self.etape.get_formule()
38 # on est dans le cas d'une fonction
39 return (self.nom,'REEL','(REEL:x)','''bidon''')
41 # On ajoute la classe formule pour etre cohérent avec la
42 # modification de C Durand sur la gestion des formules dans le superviseur
43 # On conserve l'ancienne classe fonction (ceinture et bretelles)
44 class fonction(FONCTION) : pass
46 from Extensions import param2
47 class formule(FONCTION) :
48 def __call__(self,*val):
49 if len(val) != len(self.nompar):
50 raise TypeError(" %s() takes exactly %d argument (%d given)" % (self.nom,len(self.nompar),len(val)))
51 return param2.Unop2(self.nom,self.real_call,val)
53 def real_call(self,*val):
54 if hasattr(self.parent,'contexte_fichier_init'):
55 context=self.parent.contexte_fichier_init
58 for param in self.nompar :
62 res=eval(self.expression,self.jdc.const_context, context)
65 print '! '+string.ljust('Erreur evaluation formule '+self.nom,72)+'!'