#NEWLINE# def collect( self , * keys ) : #NEWLINE# #INDENT# ' Fetch a list of all values matching the keys supplied,\n            returning (key, value) pairs for each.\n            ' #NEWLINE# items = [ ] #NEWLINE# for key in keys : #NEWLINE# #INDENT# if key . endswith ( '*' ) : #NEWLINE# #INDENT# ( key , explode ) = ( key [ : ( - 1 ) ] , True ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# explode = False #NEWLINE# #UNINDENT# if ( ':' in key ) : #NEWLINE# #INDENT# ( key , max_length ) = key . partition ( ':' ) [ 0 : : 2 ] #NEWLINE# max_length = int ( max_length ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# max_length = None #NEWLINE# #UNINDENT# value = self . values . get ( key ) #NEWLINE# if isinstance ( value , dict ) : #NEWLINE# #INDENT# if ( not value ) : #NEWLINE# #INDENT# items . append ( ( key , None ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if explode : #NEWLINE# #INDENT# items . extend ( ( ( key , _ ) for _ in value . items ( ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# items . append ( ( key , value ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( value , ( tuple , list ) ) : #NEWLINE# #INDENT# if explode : #NEWLINE# #INDENT# items . extend ( ( ( key , _ ) for _ in value ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# items . append ( ( key , list ( value ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( max_length is not None ) : #NEWLINE# #INDENT# items . append ( ( key , value [ : max_length ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# items . append ( ( key , value ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return [ ( key , value ) for ( key , value ) in items if ( value is not None ) ]