#NEWLINE# def resolve( self , context , quiet = True ) : #NEWLINE# #INDENT# '\n        Return an object described by the accessor by traversing the attributes\n        of context.\n\n        ' #NEWLINE# try : #NEWLINE# #INDENT# obj = context #NEWLINE# for level in self . levels : #NEWLINE# #INDENT# if isinstance ( obj , dict ) : #NEWLINE# #INDENT# obj = obj [ level ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( isinstance ( obj , list ) or isinstance ( obj , tuple ) ) : #NEWLINE# #INDENT# obj = obj [ int ( level ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if callable ( getattr ( obj , obj ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# obj = getattr ( obj , level ) ( ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# obj = getattr ( obj , level ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# display = ( 'get_%s_display' % level ) #NEWLINE# obj = ( getattr ( obj , display ) ( ) if hasattr ( obj , display ) else getattr ( obj , level ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( not obj ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# return obj #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# if quiet : #NEWLINE# #INDENT# return '' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise e