Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/cwltool/flatten.py @ 2:6af9afd405e9 draft
"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
author | shellac |
---|---|
date | Thu, 14 May 2020 14:56:58 -0400 |
parents | 26e78fe6e8c4 |
children |
comparison
equal
deleted
inserted
replaced
1:75ca89e9b81c | 2:6af9afd405e9 |
---|---|
1 from __future__ import absolute_import | |
2 | |
3 from typing import Any, Callable, List, Text, cast | |
4 | |
5 # http://rightfootin.blogspot.com/2006/09/more-on-python-flatten.html | |
6 | |
7 | |
8 def flatten(l, ltypes=(list, tuple)): | |
9 # type: (Any, Any) -> List[Any] | |
10 if l is None: | |
11 return [] | |
12 if not isinstance(l, ltypes): | |
13 return [l] | |
14 | |
15 ltype = type(l) | |
16 l = list(l) | |
17 i = 0 | |
18 while i < len(l): | |
19 while isinstance(l[i], ltypes): | |
20 if not l[i]: | |
21 l.pop(i) | |
22 i -= 1 | |
23 break | |
24 else: | |
25 l[i:i + 1] = l[i] | |
26 i += 1 | |
27 return cast(Callable[[Any], List[Any]], ltype)(l) |