Skip to content

Commit 22e7be5

Browse files
committed
Improve code according to review
1 parent 7481dd9 commit 22e7be5

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pyslicer/utils/validators.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class SDBaseValidator(object):
1717
__metaclass__ = abc.ABCMeta
1818

1919
def check_dictionary_value(self, dictionary_value):
20-
print dictionary_value
2120
if isinstance(dictionary_value, dict):
2221
self.check_dictionary(dictionary_value)
2322
elif isinstance(dictionary_value, list):
@@ -28,12 +27,20 @@ def check_dictionary_value(self, dictionary_value):
2827
"This query has invalid keys or values.")
2928

3029
def check_dictionary(self, dictionary):
30+
if not dictionary:
31+
raise exceptions.InvalidQueryException(
32+
"This query has invalid keys or values.")
33+
3134
for key in dictionary:
3235
dictionary_value = dictionary[key]
3336
self.check_dictionary_value(dictionary_value)
3437

35-
def check_list(self, dictionary):
36-
for dictionary_value in dictionary:
38+
def check_list(self, dictionary_list):
39+
if not dictionary_list:
40+
raise exceptions.InvalidQueryException(
41+
"This query has invalid keys or values.")
42+
43+
for dictionary_value in dictionary_list:
3744
self.check_dictionary_value(dictionary_value)
3845

3946
def __init__(self, dictionary):

0 commit comments

Comments
 (0)