<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> class Error ( Exception ) : <EOL> """<STR_LIT>""" <EOL> class DefinateConfigError ( Error ) : <EOL> """<STR_LIT>""" <EOL> class YamlValidator ( object ) : <EOL> """<STR_LIT>""" <EOL> def CheckConfigurationItem ( self , dictionary , item , typ = None ) : <EOL> """<STR_LIT>""" <EOL> if not dictionary or item not in dictionary : <EOL> raise DefinateConfigError ( '<STR_LIT>' <EOL> % ( item , dictionary ) ) <EOL> if typ and type ( dictionary [ item ] ) is not typ : <EOL> raise DefinateConfigError ( '<STR_LIT>' % <EOL> ( item , str ( type ( dictionary [ item ] ) ) , str ( typ ) ) ) <EOL> def CheckConfiguration ( self , config , structure , max_recursion_depth = <NUM_LIT:30> ) : <EOL> """<STR_LIT>""" <EOL> max_depth = max_recursion_depth - <NUM_LIT:1> <EOL> if max_depth <= <NUM_LIT:0> : <EOL> raise DefinateConfigError ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> if type ( structure ) in [ dict , list ] : <EOL> for item in structure : <EOL> value = item <EOL> if type ( structure ) is dict : <EOL> value = structure [ item ] <EOL> self . CheckConfigurationItem ( config , item , typ = type ( value ) ) <EOL> if type ( value ) is dict : <EOL> self . CheckConfiguration ( config [ item ] , value , max_depth ) <EOL> elif type ( value ) is list : <EOL> for ( i , list_value ) in enumerate ( value ) : <EOL> self . CheckConfiguration ( config [ item ] [ i ] , list_value , max_depth ) <EOL> elif type ( structure ) is type ( config ) : <EOL> return <EOL> else : <EOL> raise DefinateConfigError ( '<STR_LIT>' % ( <EOL> config , str ( type ( config ) ) , str ( structure ) ) ) </s>
