def __figure_out_task_attribute_and_operator(criteria):
swap_operands = False
if '__' in criteria:
attribute, op = criteria.split('__')
op = get_operator_function(op)
else:
attribute, op = criteria, operator.eq
if not hasattr(Task, attribute):
if hasattr(Task, attribute + 's'):
op = operator.contains
attribute += 's'
else:
raise RuntimeError("Task doesn't have such attribute.")
elif op is operator.contains:
swap_operands = True
return attribute, op, swap_operands
评论列表
文章目录