Skip to content

Commit

Permalink
Added script to convert from townscript format to mailman format.
Browse files Browse the repository at this point in the history
  • Loading branch information
bravegnu committed Aug 7, 2019
1 parent b7e6cc3 commit d564c56
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions scripts/townscript2mailman.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""Usage: townscript2mailman LAST_REGID < townscript-file.txt > mailman-format.txt)
The ticket purchase data from townscript is available in CSV
format. The last registration ID that was already added
inpycon-announce needs to be kept track of. This needs to provided as
argument to the script. Only the registration greater than LAST_REGID
will be provided in Mailman format.
NOTE: Mailman gets timedout if more than 100 users are added in
bulk. So do not add more that 100 users at a time to Mailman.
"""
import sys
import csv

email_list = set()
try:
last_regid = int(sys.argv[1])
except (IndexError, ValueError):
print("Usage: townscript2mailman.py LAST_REGID")
exit(1)

reader = csv.reader(sys.stdin)
for i, line in enumerate(reader):
if i == 0:
continue

email = line[2]
name = line[1]
regid = int(line[0])

if email in email_list:
continue

if regid <= last_regid:
continue

email_list.add(email)

print("{} <{}>".format(name, email))

0 comments on commit d564c56

Please sign in to comment.