always use get_operator, avoid case-insensitive match if possible

This commit is contained in:
j 2016-06-29 23:58:29 +02:00
commit e9863c238e
24 changed files with 289 additions and 370 deletions

View file

@ -0,0 +1,36 @@
def get_operator(op, type='str'):
return {
'str': {
'==': '',
'===': '',
'>': '__gt',
'>=': '__gte',
'<': '__lt',
'<=': '__lte',
'^': '__startswith',
'$': '__endswith',
},
'istr': {
'==': '__iexact',
'===': '',
'>': '__gt',
'>=': '__gte',
'<': '__lt',
'<=': '__lte',
'^': '__istartswith',
'$': '__iendswith',
},
'int': {
'==': '',
'>': '__gt',
'>=': '__gte',
'<': '__lt',
'<=': '__lte',
}
}[type].get(op, {
'str': '__contains',
'istr': '__icontains',
'int': ''
}[type])