-
Notifications
You must be signed in to change notification settings - Fork 77
/
split.py
42 lines (31 loc) · 1.13 KB
/
split.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from pprint import pprint
from riko.bado import coroutine
from riko.collections import SyncPipe, AsyncPipe
p385_conf = {'type': 'date'}
p385_in = {'content': '12/2/2014'}
p405_conf = {'format': '%B %d, %Y'}
p393_conf = {
'attrs': [
{'value': {'terminal': 'date', 'path': 'dateformat'}, 'key': 'date'},
{'value': {'terminal': 'year', 'path': 'year'}, 'key': 'year'}]}
p385_kwargs = {'conf': p385_conf, 'inputs': p385_in}
def pipe(test=False):
s1, s2 = (SyncPipe('input', test=test, **p385_kwargs)
.dateformat(conf=p405_conf)
.split()
.output)
p393_kwargs = {'conf': p393_conf, 'date': s1, 'year': s2, 'test': test}
stream = SyncPipe('itembuilder', **p393_kwargs).list
for i in stream:
pprint(i)
return stream
@coroutine
def async_pipe(reactor, test=False):
s1, s2 = yield (AsyncPipe('input', test=test, **p385_kwargs)
.dateformat(conf=p405_conf)
.split()
.output)
p393_kwargs = {'conf': p393_conf, 'date': s1, 'year': s2, 'test': test}
stream = yield AsyncPipe('itembuilder', **p393_kwargs).list
for i in stream:
pprint(i)