-
Notifications
You must be signed in to change notification settings - Fork 1
/
process.py
executable file
·59 lines (42 loc) · 1.5 KB
/
process.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
import logging
from processor import sources, outputs, run_pipeline
from twiggy_goodies.setup import setup_logging
from settings import *
setup_logging('processor.log')
def if_ios(item):
if item['data']['namespace'] == 'ios':
return item
def if_android(item):
if item['data']['namespace'] == 'android':
return item
def prepare_for_slack(item):
data = item['data']
versions = ', '.join(v['number']
for v in data['versions'])
return dict(text='{namespace}/{name} {versions}'.format(
namespace=data['namespace'],
name=data['name'],
versions=versions))
def prepare_for_mail(item):
data = item['data']
versions = ', '.join(v['number']
for v in data['versions'])
subject = '{namespace}/{name} {versions}'.format(
namespace=data['namespace'],
name=data['name'],
versions=versions)
# actually, some template formatter could be used here
def format_version(v):
return """<h1>{number}</h1>
{content}""".format(**v)
body = '\n\n'.join(map(format_version, data['versions']))
return dict(subject=subject,
body=body)
run_pipeline(
sources.web.hook(**LISTEN_ON),
outputs.fanout(
[if_ios, outputs.fanout(
[prepare_for_slack, outputs.slack(IOS_TEAM_CHAT)],
[prepare_for_mail, outputs.email(**IOS_MAILLIST)])],
[if_android, prepare_for_slack, outputs.slack(ANDROID_TEAM_CHAT)]))