Package Ganga :: Package GPIDev :: Module TypeCheck
[hide private]
[frames] | no frames]

Source Code for Module Ganga.GPIDev.TypeCheck

 1  # NOTICE: 
 2  # this module is used by config system to configure logging therefore the logger 
 3  # requires special handling 
 4  # this module must be importable without any side-effect, especially without 
 5  # creation of loggers by surrounding packages... 
 6   
 7  from Ganga.Utility.util import importName 
 8   
9 -def _valueTypeAllowed( val, valTypeList,logger=None):
10 for _t in valTypeList: 11 _dotMod = _t.split('.') 12 if len(_dotMod) > 1: 13 if not hasattr( val, '_proxyClass' ): 14 # val is probably a normal Python object. 15 continue 16 _type = importName( '.'.join(_dotMod[0:-1]), _dotMod[-1] ) 17 _val = val 18 else: # Native Python type 19 try: 20 _type = eval( _t ) # '_type' is actually the class name 21 except NameError: 22 logger.error( "Invalid native Python type: '%s'" % _t ) 23 continue 24 _val = val 25 # Deal with the case where type is None. 26 if _type is None: 27 if _val is None: 28 return True 29 else: 30 continue 31 elif isinstance( _val, _type ): 32 return True 33 return False
34