Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
raise an exception if mail is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed May 2, 2016
1 parent 5998c1d commit 1dce7c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Expand Up @@ -113,7 +113,7 @@ def test_enumerate_feedback(self):
xls = os.path.join(data, "groupes_eleves_pitch.xlsx")
df = pandas.read_excel(xls, sheetname=0, index=False)
comment = pandas.read_excel(xls, sheetname=1, header=None, index=False)
mails = list(enumerate_feedback(df, comment))
mails = list(enumerate_feedback(df, comment, exc=False, fLOG=fLOG))
for i, m in enumerate(mails):
fLOG("------------", i)
name = os.path.join(temp, "m%d.html" % i)
Expand Down
8 changes: 7 additions & 1 deletion src/ensae_teaching_cs/automation_students/send_feedback.py
Expand Up @@ -29,7 +29,7 @@ def enumerate_feedback(df1, df2, col_group="Groupe", col_subject="Sujet",
col_name="Name", subject="Projet informatique, feedback sur le pitch",
begin="Bonjour,\n\nVoici mon feedback sur votre pitch. Ce mail est automatisé. Veuillez vérifier les informations.\n\n",
end="Xavier", text_comments="Remarques générales", cc=None,
template=template_mail_feedback, engine="jinja2", fLOG=noLOG):
template=template_mail_feedback, engine="jinja2", exc=True, fLOG=noLOG):
"""
sends feedback to students
Expand All @@ -47,6 +47,7 @@ def enumerate_feedback(df1, df2, col_group="Groupe", col_subject="Sujet",
@param template template of the mail
@param text_comments sentance before the general comments
@param engine engine for the template
@param exc raise an exception if there is no mail
@return list of mails
Example of dataframe containing feedback:
Expand Down Expand Up @@ -108,4 +109,9 @@ def sums2(spl):
k = k[4:]
context[k] = v
text = apply_template(template, context, engine=engine)
if mail is None or "@" not in mail:
if exc:
raise ValueError("No mail for:\n" + text)
else:
fLOG("No mail for:\n" + text)
yield (mail, text)

0 comments on commit 1dce7c5

Please sign in to comment.