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"]