#NEWLINE# @ staticmethod #NEWLINE# def validate_config_item( spec , item = 'item not in config!@#' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if ( item . lower ( ) == 'none' ) : #NEWLINE# #INDENT# item = None #NEWLINE# #UNINDENT# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# default = 'default required!@#' #NEWLINE# if ( '|' in spec ) : #NEWLINE# #INDENT# ( item_type , default ) = spec . split ( '|' ) #NEWLINE# if ( ( type ( default ) is str ) and ( default . lower ( ) == 'none' ) ) : #NEWLINE# #INDENT# default = None #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# item_type = spec #NEWLINE# #UNINDENT# if ( item == 'item not in config!@#' ) : #NEWLINE# #INDENT# if ( default == 'default required!@#' ) : #NEWLINE# #INDENT# log . error ( 'Required setting missing from config file. Run with verbose logging and look for the last ConfigProcessor entry above this line to see where the problem is.' ) #NEWLINE# sys . exit ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# item = default #NEWLINE# #UNINDENT# #UNINDENT# if ( item_type == 'list' ) : #NEWLINE# #INDENT# return Util . string_to_list ( item ) #NEWLINE# #UNINDENT# if ( item_type == 'list_of_dicts' ) : #NEWLINE# #INDENT# if ( type ( item ) is list ) : #NEWLINE# #INDENT# return item #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( type ( item ) is dict ) : #NEWLINE# #INDENT# return [ item ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( item_type == 'set' ) : #NEWLINE# #INDENT# return set ( Util . string_to_list ( item ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( item_type == 'dict' ) : #NEWLINE# #INDENT# if ( ( type ( item ) is dict ) or ( type ( item ) is CaseInsensitiveDict ) ) : #NEWLINE# #INDENT# return item #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not default ) : #NEWLINE# #INDENT# return dict ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# log . error ( 'Config error. "%s" is not a dictionary' , item ) #NEWLINE# sys . exit ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( item_type == 'int' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return int ( item ) #NEWLINE# #UNINDENT# except TypeError : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( item_type == 'float' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return float ( item ) #NEWLINE# #UNINDENT# except TypeError : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( item_type in ( 'string' , 'str' ) ) : #NEWLINE# #INDENT# if item : #NEWLINE# #INDENT# return str ( item ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( item_type in ( 'boolean' , 'bool' ) ) : #NEWLINE# #INDENT# if ( type ( item ) is bool ) : #NEWLINE# #INDENT# return item #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( str ( item ) . lower ( ) in ( 'yes' , 'true' ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( item_type == 'ms' ) : #NEWLINE# #INDENT# return Timing . string_to_ms ( item ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( spec == 'secs' ) : #NEWLINE# #INDENT# return Timing . string_to_secs ( item ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( item_type == 'list_of_lists' ) : #NEWLINE# #INDENT# return Util . list_of_lists ( item )