#NEWLINE# def make_attrgetter( environment , attribute ) : #NEWLINE# #INDENT# 'Returns a callable that looks up the given attribute from a\n    passed object with the rules of the environment.  Dots are allowed\n    to access attributes of attributes.  Integer parts in paths are\n    looked up as integers.\n    ' #NEWLINE# if ( ( not isinstance ( attribute , string_types ) ) or ( ( '.' not in attribute ) and ( not attribute . isdigit ( ) ) ) ) : #NEWLINE# #INDENT# return ( lambda x : environment . getitem ( x , attribute ) ) #NEWLINE# #UNINDENT# attribute = attribute . split ( '.' ) #NEWLINE# def attrgetter( item ) : #NEWLINE# #INDENT# for part in attribute : #NEWLINE# #INDENT# if part . isdigit ( ) : #NEWLINE# #INDENT# part = int ( part ) #NEWLINE# #UNINDENT# item = environment . getitem ( item , part ) #NEWLINE# #UNINDENT# return item #NEWLINE# #UNINDENT# return attrgetter