-
Notifications
You must be signed in to change notification settings - Fork 1
/
prep-emails.py
34 lines (28 loc) · 1.22 KB
/
prep-emails.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
"""
Prep subscription email from CSV with fields 'first', 'last', 'agency', and
'email'. Saves a CSV that can be copied into the body of an email to
[email protected] in order to manage team snippet
subscriptions.
"""
def _process(line, team='pif', status='subscribe', bundle=False):
"""Accepts a line with {first},{last},{agency},{email} and returns a
properly formatted string for subscription email."""
first, last, agency, email = [x.strip() for x in line.split(',')]
name = '%s %s' % (first, last)
if bundle:
team_bundler = {
'Ashley Jablow': 'Ashley Jablow//David Naffis',
'David Naffis': 'Ashley Jablow//David Naffis',
'Christopher Daggett': 'Christopher Daggett//Ben Getson',
'Ben Getson': 'Christopher Daggett//Ben Getson'
}
if name in team_bundler.keys():
name = team_bundler[name]
return '%s [%s],%s,%s,%s' % (name, agency, email, team, status)
def convert_csv(csv_path='subscribe.csv'):
"""Accepts a filepath string to the csv and prints out the text body for a
subscription email."""
with open(csv_path) as f:
content = f.readlines()
for l in content:
print _process(l)