ovs/vsctl: Avoid applying next() to non-iterator object

In Python 2, the builtin function next() can not be applied to
non-iterator object.
This patch fixes to use the list comprehensions and avoid applying
next() to a list type object.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
IWASE Yusuke 2016-10-20 16:48:10 +09:00 committed by FUJITA Tomonori
parent 895ddfca26
commit 513bf4c48c

View File

@ -126,8 +126,8 @@ def datum_from_string(type_, value_string, symtab=None):
def ifind(pred, seq):
try:
return next(filter(pred, seq))
except StopIteration:
return [i for i in seq if pred(i)][0]
except IndexError:
return None