Try to make the utils/listop functions return something sensible with empty input.
- Legacy-Id: 233
This commit is contained in:
parent
47a88da313
commit
5c9e46027b
|
@ -3,11 +3,17 @@ import operator
|
|||
def orl(list):
|
||||
""" Return the "or" of every element in a list.
|
||||
Used to generate "or" queries with a list of Q objects. """
|
||||
return reduce(operator.__or__, list)
|
||||
if list:
|
||||
return reduce(operator.__or__, list)
|
||||
else:
|
||||
return None
|
||||
|
||||
def flattenl(list):
|
||||
""" Flatten a list one level, e.g., turn
|
||||
[ ['a'], ['b'], ['c', 'd'] ] into
|
||||
[ 'a', 'b', 'c', 'd' ]
|
||||
"""
|
||||
return reduce(operator.__concat__, list)
|
||||
if list:
|
||||
return reduce(operator.__concat__, list)
|
||||
else:
|
||||
return []
|
Loading…
Reference in a new issue