def build_condition(filter_map, using=CONDITIONS):
if not filter_map:<EOL><INDENT>return<EOL><DEDENT>filters = {}<EOL>dynamizer = Dynamizer()<EOL>for field_and_op, value in filter_map.items():<EOL><INDENT>field_bits = field_and_op.split('<STR_LIT>')<EOL>fieldname = '<STR_LIT>'.join(field_bits[:-<NUM_LIT:1>])<EOL>try:<EOL><INDENT>op = using[field_bits[-<NUM_LIT:1>]]<EOL><DEDENT>except KeyError:<EOL><INDENT>raise ConditionNotRecognizedException(<EOL>"<STR_LIT>" % (<EOL>field_bits[-<NUM_LIT:1>],<EOL>field_and_op<EOL>)<EOL>)<EOL><DEDENT>lookup = {<EOL>'<STR_LIT>': [],<EOL>'<STR_LIT>': op,<EOL>}<EOL>if field_bits[-<NUM_LIT:1>] == '<STR_LIT:null>':<EOL><INDENT>del lookup['<STR_LIT>']<EOL>if value is False:<EOL><INDENT>lookup['<STR_LIT>'] = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>lookup['<STR_LIT>'] = '<STR_LIT>'<EOL><DEDENT><DEDENT>elif field_bits[-<NUM_LIT:1>] == '<STR_LIT>':<EOL><INDENT>if len(value) == <NUM_LIT:2> and isinstance(value, (list, tuple)):<EOL><INDENT>lookup['<STR_LIT>'].append(<EOL>dynamizer.encode(value[<NUM_LIT:0>])<EOL>)<EOL>lookup['<STR_LIT>'].append(<EOL>dynamizer.encode(value[<NUM_LIT:1>])<EOL>)<EOL><DEDENT><DEDENT>elif field_bits[-<NUM_LIT:1>] == '<STR_LIT>':<EOL><INDENT>for val in value:<EOL><INDENT>lookup['<STR_LIT>'].append(dynamizer.encode(val))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if isinstance(value, (list, tuple)):<EOL><INDENT>value = set(value)<EOL><DEDENT>lookup['<STR_LIT>'].append(<EOL>dynamizer.encode(value)<EOL>)<EOL><DEDENT>filters[fieldname] = lookup<EOL><DEDENT>return filters<EOL>
Implement the conditions described in
    docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Condition.html