#NEWLINE# def resolve_relative_to( self , view , template ) : #NEWLINE# #INDENT# if ( not isinstance ( template , ( collections . Mapping , MappingTemplate ) ) ) : #NEWLINE# #INDENT# raise ConfigTemplateError ( 'relative_to may only be used when getting multiple values.' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . relative_to == view . key ) : #NEWLINE# #INDENT# raise ConfigTemplateError ( '{0} is relative to itself' . format ( view . name ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . relative_to not in view . parent . keys ( ) ) : #NEWLINE# #INDENT# self . fail ( 'needs sibling value "{0}" to expand relative path' . format ( self . relative_to ) , view ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# old_template = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# old_template . update ( template . subtemplates ) #NEWLINE# next_template = MappingTemplate ( { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# next_relative = self . relative_to #NEWLINE# while ( next_relative is not None ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# rel_to_template = old_template . pop ( next_relative ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# if ( next_relative in template . subtemplates ) : #NEWLINE# #INDENT# raise ConfigTemplateError ( '{0} and {1} are recursively relative' . format ( view . name , self . relative_to ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ConfigTemplateError ( ( "missing template for {0}, needed to expand {1}'s" + 'relative path' ) . format ( self . relative_to , view . name ) ) #NEWLINE# #UNINDENT# #UNINDENT# next_template . subtemplates [ next_relative ] = rel_to_template #NEWLINE# next_relative = rel_to_template . relative_to #NEWLINE# #UNINDENT# return view . parent . get ( next_template ) [ self . relative_to ]