File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -28,16 +28,17 @@ def add_arguments(self, parser):
28
28
def raise_value_error (error_type , value ):
29
29
"""Raise a ValueError with a clean error message in python 2.7 and 3.
30
30
:param string value: the attempted value."""
31
+ valid_texts = []
32
+ base = "--question-id {} / --question-text '{}'\n "
31
33
if error_type in ["question-id" , "question-text" ]:
32
- base = "--question-id {} / --question-text '{}'\n "
33
- valids = [(q .pk , q .text ) for q in Question .objects .all ()]
34
+ valid_texts = [(q .pk , q .text ) for q in Question .objects .all ()]
34
35
elif error_type in ["survey-name" , "survey-id" ]:
35
36
base = "--survey-id {} / --survey-name '{}'\n "
36
- valids = [(s .pk , s .name ) for s in Survey .objects .all ()]
37
+ valid_texts = [(s .pk , s .name ) for s in Survey .objects .all ()]
37
38
msg = f"You tried to get --{ error_type } '{ value } ' "
38
- if valids :
39
+ if valid_texts :
39
40
msg += "but is does not exists. Possibles values :\n "
40
- for primary_key , name in valids :
41
+ for primary_key , name in valid_texts :
41
42
msg += base .format (primary_key , name )
42
43
msg = msg [:- 1 ] # Remove last \n
43
44
else :
You can’t perform that action at this time.
0 commit comments