-
Notifications
You must be signed in to change notification settings - Fork 0
/
type_checkers.py
56 lines (41 loc) · 1.24 KB
/
type_checkers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import conditions
import conflicts
def ge_int(lbound):
def f(val):
val = int(val)
if val < lbound:
raise ValueError
return val
return f
def sort_order(val):
val = str(val)
val = val.upper()
if val not in ['ASC', 'DESC']:
raise ValueError
return val
def model_field(model):
def check_function(field_name):
if field_name.lower() not in [field.qualified_col_name.lower() for field in model.fields_short_resolved]:
raise ValueError
return field_name
return check_function
def model_field_own(model):
def check_function(field_name):
if field_name.lower() not in [field.qualified_col_name.lower() for field in model.fields]:
raise ValueError
return field_name
return check_function
def logic_operators(val):
if val not in conditions.BasicCondition.logic_operators:
raise ValueError
return val
def compare_operators(val):
if val not in conditions.BasicCondition.compare_operators:
raise ValueError
return val
def conflict(val):
val = val.lower()
for conflict in conflicts.all_conflicts:
if val == conflict.alias.lower():
return conflict
raise ValueError