def _gen_combinator(variants, _merge=True):
if not hasattr(variants, '__iter__'):
return [variants] if variants is not None else []
res = []
need_product = False
for var in variants:
if isinstance(var, list):
sol = _gen_combinator(var, _merge=False)
res.append(sol)
need_product = True
elif var is not None:
res.append(var)
if need_product:
producted = itertools.product(*res)
if _merge:
# TODO(buglloc): ??!
return list(six.moves.map(_merge_variants, producted))
return producted
elif _merge:
return list(six.moves.map(_merge_variants, [res]))
return res
评论列表
文章目录