From 1d376d6b5656022f3e28e2fbd1267e5c4b7c5853 Mon Sep 17 00:00:00 2001 From: jeanGaston Date: Sun, 20 Oct 2024 19:14:36 +0200 Subject: [PATCH] Change in files organization Readme updates fix bu in env.py --- README.md | 19 ++++++++++--------- src/draw.py | 5 +++-- src/emailer.py | 2 +- src/main.py | 10 +++++----- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 1836dd6..3dc6179 100644 --- a/README.md +++ b/README.md @@ -17,20 +17,18 @@ This Python project automates the process of organizing a Secret Santa event. It ```bash secret-santa/ │ -├── config/ -│ └── env.py # Configuration settings (SMTP, file paths, etc.) -│ ├── src/ │ ├── draw.py # Logic for drawing names │ ├── emailer.py # Email sending functionality │ ├── file_io.py # File handling (CSV reading/writing) │ ├── main.py # Main program logic -│ └── utils.py # Utility functions (date, time handling) +│ ├── utils.py # Utility functions (date, time handling) +│ └── env.py # Configuration settings (SMTP, file paths, etc.) │ └── README.md # Project readme ``` -### `config/env.py` +### `src/env.py` The configuration file contains SMTP settings, file paths, and customizable parameters for the draw. @@ -40,7 +38,7 @@ Example `env.py`: SMTP_SERVER = "smtp.example.com" SMTP_PORT = 25 SENDER_EMAIL = "santa@example.com" -CSV_FILE_PATH = "secret_santa_DB.csv" +CSV_FILE_PATH = r"secret_santa_DB.csv" DRAW_PER_PERSON = 2 # Choose 1 or 2 recipients per person # Email content @@ -68,12 +66,15 @@ This email was sent automatically, please do not reply. 1. Clone the repository or download the script files. 2. Ensure you have Python installed on your system. If not, download and install Python from [here](https://www.python.org/downloads/). -3. Set up the `env.py` file in the `config/` directory, adjusting the SMTP settings, CSV file path, and draw parameters as needed. - -Example structure of the CSV file: +3. Set up the `env.py` file in the `src/` directory, adjusting the SMTP settings, CSV file path, and draw parameters as needed. +Example structure of the CSV file +with the following colunms ```csv Name,Email,Last_Year_Recipient_1,Last_Year_Recipient_2 +``` + +```csv Alice,alice@example.com,Bob,Charlie Bob,bob@example.com,Alice,David Charlie,charlie@example.com,David,Alice diff --git a/src/draw.py b/src/draw.py index b3ed789..bc90994 100644 --- a/src/draw.py +++ b/src/draw.py @@ -12,10 +12,11 @@ def draw_names(previous_draw, draws_per_person): new_draw = [] # Store new draw results for i in range(len(participants)): + giver = previous_draw[i][0] + email = previous_draw[i][1] + print(email) last_year_r1 = previous_draw[i][2] last_year_r2 = previous_draw[i][3] - giver = previous_draw[i][0] - email = previous_draw[i][1] available_participants = participants.copy() try: diff --git a/src/emailer.py b/src/emailer.py index c7a68ca..17e3b4b 100644 --- a/src/emailer.py +++ b/src/emailer.py @@ -1,7 +1,7 @@ import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart -from config.env import SMTP_SERVER, SMTP_PORT, SENDER_EMAIL +from env import SMTP_SERVER, SMTP_PORT, SENDER_EMAIL def send_email(receiver_email, subject, msg): """ diff --git a/src/main.py b/src/main.py index be0d425..6f575b7 100644 --- a/src/main.py +++ b/src/main.py @@ -1,8 +1,8 @@ -from config.env import CSV_FILE_PATH, DRAW_PER_PERSON, EMAIL_SUBJECT, EMAIL_BODY -from src.file_io import open_csv, save_csv -from src.draw import draw_names -from src.emailer import send_email -from src.utils import get_current_time +from env import CSV_FILE_PATH, DRAW_PER_PERSON, EMAIL_SUBJECT, EMAIL_BODY +from file_io import open_csv, save_csv +from draw import draw_names +from emailer import send_email +from utils import get_current_time from datetime import date def send_all_emails(new_draw):