Repository navigation
Expand file tree
/
Copy pathtools.py
More file actions
103 lines (71 loc) · 2.02 KB
/
Copy pathtools.py
File metadata and controls
103 lines (71 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import csv
import sqlite3
from datetime import datetime
SCHEDULE_FILE = "data/schedule.csv"
EMPLOYEE_DB = "data/employee.db"
# 1. 공연 일정 조회
def get_schedule(start_date, end_date):
schedules = []
start = datetime.strptime(start_date, "%Y-%m-%d")
end = datetime.strptime(end_date, "%Y-%m-%d")
with open(SCHEDULE_FILE, "r", encoding="utf-8-sig") as file:
reader = csv.DictReader(file)
for row in reader:
schedule_date = datetime.strptime(row["date"], "%Y-%m-%d")
if start <= schedule_date <= end:
schedules.append(row)
return schedules
# 2. 담당자 정보 조회
def get_employee(name):
connection = sqlite3.connect(EMPLOYEE_DB)
cursor = connection.cursor()
cursor.execute(
"""
SELECT name, email
FROM employees
WHERE name = ?
""",
(name,)
)
employee = cursor.fetchone()
connection.close()
if employee is None:
return {
"error": f"{name} 담당자를 찾을 수 없습니다."
}
return {
"name": employee[0],
"email": employee[1]
}
# 3. 담당자 업무량 계산
def calculate_workload(employee):
count = 0
with open(SCHEDULE_FILE, "r", encoding="utf-8-sig") as file:
reader = csv.DictReader(file)
for row in reader:
if row["manager"] == employee:
count += 1
return {
"employee": employee,
"schedule_count": count
}
# 4. 이메일 초안 생성
def create_email_draft(employee, schedules):
schedule_text = ""
for schedule in schedules:
schedule_text += (
f"- {schedule['date']} "
f"{schedule['performance']}\n"
)
subject = "공연 일정 안내"
body = f"""안녕하세요, {employee}님.
담당 공연 일정을 안내드립니다.
{schedule_text}
확인 부탁드립니다.
감사합니다.
"""
return {
"employee": employee,
"subject": subject,
"body": body
}