ruslanmv commited on
Commit
29ab0f4
·
verified ·
1 Parent(s): d53ccad

Upload tools.py

Browse files
Files changed (1) hide show
  1. tools.py +42 -0
tools.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from datetime import datetime
3
+ import json
4
+ def store_interview_report(report_content, folder_path="reports"):
5
+ """
6
+ Stores the interview report in a specified reports folder.
7
+
8
+ Args:
9
+ report_content (str): The content of the report to store.
10
+ folder_path (str): The directory where the report will be saved.
11
+
12
+ Returns:
13
+ str: The file path of the saved report.
14
+ """
15
+ os.makedirs(folder_path, exist_ok=True)
16
+ timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
17
+ file_path = os.path.join(folder_path, f"interview_report_{timestamp}.txt")
18
+
19
+ try:
20
+ with open(file_path, "w", encoding="utf-8") as file:
21
+ file.write(report_content)
22
+ print(f"[DEBUG] Interview report saved at {file_path}")
23
+ return file_path
24
+ except Exception as e:
25
+ print(f"[ERROR] Failed to save interview report: {e}")
26
+ return None
27
+
28
+
29
+ # Function to read questions from JSON
30
+ def read_questions_from_json(file_path):
31
+ if not os.path.exists(file_path):
32
+ raise FileNotFoundError(f"The file '{file_path}' does not exist.")
33
+
34
+ with open(file_path, 'r') as f:
35
+ questions_list = json.load(f)
36
+
37
+ if not questions_list:
38
+ raise ValueError("The JSON file is empty or has invalid content.")
39
+
40
+ return questions_list
41
+
42
+