#NEWLINE# def convert( self , value , view ) : #NEWLINE# #INDENT# 'Ensure that the value follows at least one template.\n        ' #NEWLINE# is_mapping = isinstance ( self . template , MappingTemplate ) #NEWLINE# for candidate in self . allowed : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if is_mapping : #NEWLINE# #INDENT# if ( isinstance ( candidate , Filename ) and candidate . relative_to ) : #NEWLINE# #INDENT# next_template = candidate . template_with_relatives ( view , exc . template ) #NEWLINE# next_template . subtemplates [ view . key ] = as_template ( candidate ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# next_template = MappingTemplate ( { #NEWLINE# #INDENT# view . key : candidate , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# return view . parent . get ( next_template ) [ view . key ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return view . get ( candidate ) #NEWLINE# #UNINDENT# #UNINDENT# except ConfigTemplateError : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# except ConfigError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# except ValueError as exc : #NEWLINE# #INDENT# raise ConfigTemplateError ( exc ) #NEWLINE# #UNINDENT# #UNINDENT# self . fail ( 'must be one of {0}, not {1}' . format ( repr ( self . allowed ) , repr ( value ) ) , view )