<s> import itertools <EOL> from _init_environment import SetHostMTurkConnection <EOL> from _init_environment import config_environment <EOL> def description_filter ( substring ) : <EOL> return lambda hit : substring in hit . Title <EOL> def disable_hit ( hit ) : <EOL> return conn . disable_hit ( hit . HITId ) <EOL> def dispose_hit ( hit ) : <EOL> for assignment in conn . get_assignments ( hit . HITId ) : <EOL> if assignment . AssignmentStatus == '<STR_LIT>' : <EOL> conn . approve_assignment ( assignment . AssignmentId ) <EOL> return conn . dispose_hit ( hit . HITId ) <EOL> def cleanup ( ) : <EOL> """<STR_LIT>""" <EOL> config_environment ( ) <EOL> global conn <EOL> conn = SetHostMTurkConnection ( ) <EOL> is_boto = description_filter ( '<STR_LIT>' ) <EOL> print '<STR_LIT>' <EOL> all_hits = list ( conn . get_all_hits ( ) ) <EOL> is_reviewable = lambda hit : hit . HITStatus == '<STR_LIT>' <EOL> is_not_reviewable = lambda hit : not is_reviewable ( hit ) <EOL> hits_to_process = filter ( is_boto , all_hits ) <EOL> hits_to_disable = filter ( is_not_reviewable , hits_to_process ) <EOL> hits_to_dispose = filter ( is_reviewable , hits_to_process ) <EOL> print '<STR_LIT>' % ( len ( hits_to_disable ) , len ( hits_to_dispose ) ) <EOL> map ( disable_hit , hits_to_disable ) <EOL> map ( dispose_hit , hits_to_dispose ) <EOL> total_hits = len ( all_hits ) <EOL> hits_processed = len ( hits_to_process ) <EOL> skipped = total_hits - hits_processed <EOL> fmt = '<STR_LIT>' <EOL> print fmt % vars ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> cleanup ( ) </s>
