#NEWLINE# def select( source , selection , invert = False ) : #NEWLINE# #INDENT# selections = [ ] #NEWLINE# for ( key , values ) in selection . items ( ) : #NEWLINE# #INDENT# if ( '__' in key ) : #NEWLINE# #INDENT# ( column , method ) = key . split ( '__' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# column = key #NEWLINE# method = 'eq' #NEWLINE# #UNINDENT# if ( not hasattr ( Column , method ) ) : #NEWLINE# #INDENT# raise ValueError ( '{method} is not a valid selector. Choose from: {options}' . format ( method = method , options = ', ' . join ( Column . selectors ) ) ) #NEWLINE# #UNINDENT# if invert : #NEWLINE# #INDENT# method = EXCLUSION [ method ] #NEWLINE# #UNINDENT# column = source [ column ] #NEWLINE# selector = getattr ( invert , method ) #NEWLINE# if ( not isinstance ( values , ( list , tuple ) ) ) : #NEWLINE# #INDENT# values = [ values ] #NEWLINE# #UNINDENT# for value in values : #NEWLINE# #INDENT# selections . append ( selector ( value ) ) #NEWLINE# #UNINDENT# #UNINDENT# return selections