#NEWLINE# def validate_item( self , item , validator , validation_failure_info ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if ( item . lower ( ) == 'none' ) : #NEWLINE# #INDENT# item = None #NEWLINE# #UNINDENT# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# if ( ':' in validator ) : #NEWLINE# #INDENT# validator = validator . split ( ':' ) #NEWLINE# item = Util . event_config_to_dict ( item ) #NEWLINE# return_dict = dict ( ) #NEWLINE# for ( k , v ) in item . iteritems ( ) : #NEWLINE# #INDENT# return_dict [ self . validate_item ( k , validator [ 0 ] , validation_failure_info ) ] = self . validate_item ( v , validator [ 1 ] , validation_failure_info ) #NEWLINE# #UNINDENT# item = return_dict #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( '%' in validator ) : #NEWLINE# #INDENT# if ( type ( item ) is str ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# item = eval ( validator . replace ( '%' , ( ( "'" + item ) + "'" ) ) ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# self . validation_error ( item , validation_failure_info ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# item = None #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( validator == 'str' ) : #NEWLINE# #INDENT# if ( item is not None ) : #NEWLINE# #INDENT# item = str ( item ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# item = None #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( validator == 'float' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# item = float ( item ) #NEWLINE# #UNINDENT# except ( TypeError , ValueError ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( validator == 'int' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# item = int ( item ) #NEWLINE# #UNINDENT# except ( TypeError , ValueError ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( validator in ( 'bool' , 'boolean' ) ) : #NEWLINE# #INDENT# if ( type ( item ) is str ) : #NEWLINE# #INDENT# if ( item . lower ( ) in [ 'false' , 'f' , 'no' , 'disable' , 'off' ] ) : #NEWLINE# #INDENT# item = False #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( not item ) : #NEWLINE# #INDENT# item = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# item = True #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( validator == 'ms' ) : #NEWLINE# #INDENT# item = Timing . string_to_ms ( item ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( validator == 'secs' ) : #NEWLINE# #INDENT# item = Timing . string_to_secs ( item ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( validator == 'ticks' ) : #NEWLINE# #INDENT# item = Timing . string_to_ticks ( item ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( validator == 'ticks_int' ) : #NEWLINE# #INDENT# item = int ( Timing . string_to_ticks ( item ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( validation_failure_info == 'list' ) : #NEWLINE# #INDENT# item = Util . string_to_list ( item ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . log . error ( "Invalid Validator '%s' in config spec %s:%s" , validator , validation_failure_info [ 0 ] [ 0 ] , validation_failure_info [ 1 ] ) #NEWLINE# sys . exit ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return item