Back to index

salome-kernel  6.5.0
Classes | Functions | Variables
KERNEL_PY.kernel.datamodeler Namespace Reference

Classes

class  DataModeler

Functions

def TEST_usecase
def TEST_addAttribute
def TEST_badAttributeName
def TEST_badAttributeType
def TEST_badAttributeRange
def TEST_voidAttributeAllowed
def TEST_defaultValues

Variables

string __author__ = "gboulant"
string __date__ = "$15 avr. 2010 19:44:17$"
string TypeString = ""
int __ref_integer = 0
 TypeInteger = __ref_integer.__class__
float __ref_double = 0.0
 TypeDouble = __ref_double.__class__
list __ref_list = []
 TypeList = __ref_list.__class__
dictionary __ref_dict = {}
 TypeDictionnary = __ref_dict.__class__
list UNCHECKED_ATTRIBUTES

Function Documentation

Definition at line 201 of file datamodeler.py.

00201 
00202 def TEST_addAttribute():
00203     typemap={}
00204     typemap["stringdata"] = TypeString
00205     typemap["integerdata"] = TypeInteger
00206     data = DataModeler(typemap)
00207     data.stringdata = "a string value"
00208 
00209     ref_value = 1.3
00210     data.addAttribute(
00211         name    = "myAttr",
00212         type    = TypeDouble,
00213         range   = None,
00214         default = ref_value,
00215         void    = False)
00216 
00217     try:
00218         if data.myAttr != ref_value:
00219             return False
00220         data.myAttr = 5.3
00221         #data.myAttr = 5
00222     except Exception, e:
00223         print e
00224         return False
00225 
00226     try:
00227         data.myAttr = "bad type value"
00228         return False
00229     except Exception, e:
00230         print e
00231         return True

Definition at line 232 of file datamodeler.py.

00232 
00233 def TEST_badAttributeName():
00234     map={}
00235     map["stringdata"] = TypeString
00236     map["integerdata"] = TypeInteger
00237 
00238     data = DataModeler(map)
00239 
00240     # this should raise an exception
00241     try:
00242         data.myatt = 3
00243         return False
00244     except Exception, e:
00245         print "OK : "+str(e)
00246         return True

Definition at line 261 of file datamodeler.py.

00261 
00262 def TEST_badAttributeRange():
00263     map={}
00264     map["stringdata"] = TypeString
00265     map["integerdata"] = TypeInteger
00266 
00267     range={}
00268     ref_integervalue = 3
00269     range["integerdata"] = [1,ref_integervalue,7]
00270 
00271     data = DataModeler(map,range)
00272     # this should not raise an exception
00273     try:
00274         data.integerdata = ref_integervalue
00275         data.stringdata = "anything (no restriction has been defined)"
00276     except Exception, e:
00277         print e
00278         return False
00279 
00280     # this should raise an exception
00281     try:
00282         data.integerdata = 9999 # a value not in the range
00283         return False
00284     except Exception, e:
00285         print e
00286         return True

Definition at line 247 of file datamodeler.py.

00247 
00248 def TEST_badAttributeType():
00249     map={}
00250     map["stringdata"] = TypeString
00251     map["integerdata"] = TypeInteger
00252 
00253     data = DataModeler(map)
00254     # this should raise an exception
00255     try:
00256         data.stringdata = 2
00257         return False
00258     except Exception, e:
00259         print "OK : "+str(e)
00260         return True

Definition at line 312 of file datamodeler.py.

00312 
00313 def TEST_defaultValues():
00314     typemap={}
00315     typemap["stringdata"] = TypeString
00316     typemap["integerdata"] = TypeInteger
00317 
00318     ref_value = "my initial value"
00319     defaultmap={}
00320     defaultmap["stringdata"] = ref_value
00321 
00322     data = DataModeler(typemap=typemap,defaultmap=defaultmap)
00323     print data.stringdata
00324     if data.stringdata != ref_value:
00325         return False
00326     else:
00327         return True

Here is the call graph for this function:

Definition at line 181 of file datamodeler.py.

00181 
00182 def TEST_usecase():
00183     typemap={}
00184     typemap["stringdata"] = TypeString
00185     typemap["integerdata"] = TypeInteger
00186     typemap["anydata"] = None # can be anything
00187 
00188     data = DataModeler(typemap)
00189 
00190     sdata = "toto"
00191     idata = 3
00192     data.stringdata = sdata
00193     data.integerdata = idata
00194 
00195     data.anydata = 5.3
00196     data.anydata = "any value"
00197     data.anydata = True
00198 
00199     print data.integerdata
00200     return True

Definition at line 287 of file datamodeler.py.

00287 
00288 def TEST_voidAttributeAllowed():
00289     map={}
00290     map["stringdata"] = TypeString
00291     map["integerdata"] = TypeInteger
00292 
00293     voidmap={}
00294     voidmap["stringdata"] = True
00295 
00296     data = DataModeler(typemap=map,voidmap=voidmap)
00297     try:
00298         # this should not raise an exception
00299         data.stringdata = None
00300         print data.stringdata
00301     except Exception, e:
00302         print e
00303         return False
00304     
00305     try:
00306         # this should raise an exception
00307         data.integerdata = None
00308         return False
00309     except Exception, e:
00310         print e
00311         return True


Variable Documentation

Definition at line 21 of file datamodeler.py.

string KERNEL_PY.kernel.datamodeler.__date__ = "$15 avr. 2010 19:44:17$"

Definition at line 22 of file datamodeler.py.

Definition at line 34 of file datamodeler.py.

Definition at line 30 of file datamodeler.py.

Definition at line 28 of file datamodeler.py.

Definition at line 32 of file datamodeler.py.

Definition at line 35 of file datamodeler.py.

KERNEL_PY.kernel.datamodeler.TypeDouble = __ref_double.__class__

Definition at line 31 of file datamodeler.py.

KERNEL_PY.kernel.datamodeler.TypeInteger = __ref_integer.__class__

Definition at line 29 of file datamodeler.py.

KERNEL_PY.kernel.datamodeler.TypeList = __ref_list.__class__

Definition at line 33 of file datamodeler.py.

Definition at line 27 of file datamodeler.py.

Initial value:
00001 [
00002     "_typemap",
00003     "_rangemap",
00004     "_defaultmap",
00005     "_voidmap"
00006 ]

Definition at line 39 of file datamodeler.py.