1 |
def _xargs(iterable, cmd_len=1024): |
1✔ |
2 |
fn_len = 0
|
1✔ |
3 |
buf = [] |
1✔ |
4 |
iterable = list(iterable)
|
1✔ |
5 |
while iterable:
|
1✔ |
6 |
s = iterable.pop(0)
|
1✔ |
7 |
l = len(s) + 1 |
1✔ |
8 |
if fn_len + l >= cmd_len:
|
1✔ |
9 |
yield buf
|
× |
10 |
buf = [] |
× |
11 |
fn_len = 0
|
× |
12 |
buf.append(s) |
1✔ |
13 |
fn_len += l |
1✔ |
14 |
if buf:
|
1✔ |
15 |
yield buf
|
1✔ |