From c05b3d4e7f71ebd68b27c7f17f68fa2bac933660 Mon Sep 17 00:00:00 2001 From: Jan Grewe Date: Thu, 22 Aug 2019 10:17:15 +0200 Subject: [PATCH] check for double registrations ... i.e. do not overwrite but store and send a different csv --- email_client.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/email_client.py b/email_client.py index 1bde26a..8526d01 100644 --- a/email_client.py +++ b/email_client.py @@ -10,6 +10,7 @@ from email.message import EmailMessage import re import datetime as dt import time +import glob EMAIL_ACCOUNT = "bzigr02" EMAIL_FOLDER = "INBOX" @@ -154,7 +155,13 @@ class Participation(object): if not os.path.exists(PARTICIPANTS_FOLDER): os.mkdir(PARTICIPANTS_FOLDER) if not filename: - filename = os.path.join(PARTICIPANTS_FOLDER, "".join(self.name.split())) + ".csv" + stub = os.path.join(PARTICIPANTS_FOLDER, "".join(self.name.split())) + "*" + matches = glob.glob(stub) + if len(matches) > 0: + filename = os.path.join(PARTICIPANTS_FOLDER, "".join(self.name.split())) + "_%i" % len(matches) + ".csv" + else: + filename = os.path.join(PARTICIPANTS_FOLDER, "".join(self.name.split())) + ".csv" + header = ["LastName", "FirstName", "eMail", "Phone", "Institute", "Street", "City", "RegDate", "CareerStage", "Fee", "FarewellEvent", "GwinnerAward", "LabTour", "FoodVegetarian", "FoodVegan", "FoodGlutenFree", "FoodNoPref"]