<s> class Search : <EOL> class IsNodeBuilder ( object ) : <EOL> def __init__ ( self , name ) : <EOL> self . name = name <EOL> def __eq__ ( self , value ) : <EOL> return self . is_equal ( value ) <EOL> def is_equal ( self , value ) : <EOL> return Search . Node ( self . name , { "<STR_LIT>" : value } ) <EOL> class EqualityNodeBuilder ( IsNodeBuilder ) : <EOL> def __ne__ ( self , value ) : <EOL> return self . is_not_equal ( value ) <EOL> def is_not_equal ( self , value ) : <EOL> return Search . Node ( self . name , { "<STR_LIT>" : value } ) <EOL> class KeyValueNodeBuilder ( object ) : <EOL> def __init__ ( self , name ) : <EOL> self . name = name <EOL> def __eq__ ( self , value ) : <EOL> return self . is_equal ( value ) <EOL> def is_equal ( self , value ) : <EOL> return Search . Node ( self . name , value ) <EOL> def __ne__ ( self , value ) : <EOL> return self . is_not_equal ( value ) <EOL> def is_not_equal ( self , value ) : <EOL> return Search . Node ( self . name , not value ) <EOL> class PartialMatchNodeBuilder ( EqualityNodeBuilder ) : <EOL> def starts_with ( self , value ) : <EOL> return Search . Node ( self . name , { "<STR_LIT>" : value } ) <EOL> def ends_with ( self , value ) : <EOL> return Search . Node ( self . name , { "<STR_LIT>" : value } ) <EOL> class TextNodeBuilder ( PartialMatchNodeBuilder ) : <EOL> def contains ( self , value ) : <EOL> return Search . Node ( self . name , { "<STR_LIT>" : value } ) <EOL> class Node ( object ) : <EOL> def __init__ ( self , name , dict ) : <EOL> self . name = name <EOL> self . dict = dict <EOL> def to_param ( self ) : <EOL> return self . dict <EOL> class MultipleValueNodeBuilder ( object ) : <EOL> def __init__ ( self , name , whitelist = [ ] ) : <EOL> self . name = name <EOL> self . whitelist = whitelist <EOL> def in_list ( self , * values ) : <EOL> if isinstance ( values [ <NUM_LIT:0> ] , list ) : <EOL> values = values [ <NUM_LIT:0> ] <EOL> invalid_args = set ( values ) - set ( self . whitelist ) <EOL> if len ( self . whitelist ) > <NUM_LIT:0> and len ( invalid_args ) > <NUM_LIT:0> : <EOL> error_string = "<STR_LIT>" % ( self . name , "<STR_LIT:U+002CU+0020>" . join ( invalid_args ) ) <EOL> raise AttributeError ( error_string ) <EOL> return Search . Node ( self . name , list ( values ) ) <EOL> def __eq__ ( self , value ) : <EOL> return self . in_list ( [ value ] ) <EOL> class MultipleValueOrTextNodeBuilder ( TextNodeBuilder , MultipleValueNodeBuilder ) : <EOL> def __init__ ( self , name , whitelist = [ ] ) : <EOL> Search . MultipleValueNodeBuilder . __init__ ( self , name , whitelist ) <EOL> class RangeNodeBuilder ( object ) : <EOL> def __init__ ( self , name ) : <EOL> self . name = name <EOL> def __eq__ ( self , value ) : <EOL> return self . is_equal ( value ) <EOL> def is_equal ( self , value ) : <EOL> return Search . EqualityNodeBuilder ( self . name ) == value <EOL> def __ge__ ( self , min ) : <EOL> return self . greater_than_or_equal_to ( min ) <EOL> def greater_than_or_equal_to ( self , min ) : <EOL> return Search . Node ( self . name , { "<STR_LIT>" : min } ) <EOL> def __le__ ( self , max ) : <EOL> return self . less_than_or_equal_to ( max ) <EOL> def less_than_or_equal_to ( self , max ) : <EOL> return Search . Node ( self . name , { "<STR_LIT>" : max } ) <EOL> def between ( self , min , max ) : <EOL> return Search . Node ( self . name , { "<STR_LIT>" : min , "<STR_LIT>" : max } ) </s>
