Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _try_fetch_local_assignment(self, try_this, with_psiturk_status=None):
'''
Can accept either an assignment_id or the return of a mturk boto grab...
'''
query = Participant.query.order_by(Participant.beginhit.desc())
if with_psiturk_status:
query = query.filter(Participant.status == with_psiturk_status)
if isinstance(try_this, str): # then assume that it's an assignment_id
assignment_id = try_this
query = query.filter(Participant.assignmentid == assignment_id)
elif isinstance(try_this, dict): # then assume that it's a return from mturk
assignment = try_this
assignment_id = assignment['assignmentId']
query = query.filter(Participant.workerid == assignment['workerId'])\
.filter(Participant.assignmentid == assignment_id)
else:
raise PsiturkException('Unrecognized `try_this` value-type: {}'.format(type(try_this)))