[bitbake-devel] [PATCH 42/94] bitbake: webhob: improve validation code flow
Alex DAMIAN
alexandru.damian at intel.com
Tue Sep 24 16:52:11 UTC 2013
From: Calin Dragomir <calinx.l.dragomir at intel.com>
This patch improves the code flow in the validation method
by not repeating the split method over the same list and
by stoping at any invalid input encountered.
Signed-off-by: Calin Dragomir <calinx.l.dragomir at intel.com>
Signed-off-by: Alexandru DAMIAN <alexandru.damian at intel.com>
---
bitbake/lib/webhob/bldviewer/views.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/bitbake/lib/webhob/bldviewer/views.py b/bitbake/lib/webhob/bldviewer/views.py
index 73f7ba7..647a1f2 100644
--- a/bitbake/lib/webhob/bldviewer/views.py
+++ b/bitbake/lib/webhob/bldviewer/views.py
@@ -139,17 +139,20 @@ def _validate_input(input, model):
input_list = input.split(":")
# Check we have only one colon
- if len(input.split(":")) != 2:
+ if len(input_list) != 2:
invalid = 1
+ return None, invalid
# Check we have an equal number of terms both sides of the colon
if len(input_list[0].split(',')) != len(input_list[1].split(',')):
invalid = 1
+ return None, invalid
# Check we are looking for a valid field
valid_fields = model._meta.get_all_field_names()
for field in input_list[0].split(','):
if field not in valid_fields:
invalid = 1
+ return None, invalid
return input, invalid
--
1.8.1.2
More information about the bitbake-devel
mailing list