-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfile_handler.py
More file actions
29 lines (25 loc) · 831 Bytes
/
file_handler.py
File metadata and controls
29 lines (25 loc) · 831 Bytes
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
def get_file_contents(file_paths):
"""
Reads the content of the specified files.
Args:
file_paths: A list or set of file paths.
Returns:
A dictionary where keys are file paths and values are their contents.
"""
file_contents = {}
for file_path in file_paths:
try:
with open(file_path, "r") as f:
file_contents[file_path] = f.read()
except FileNotFoundError:
print(f"Warning: File not found: {file_path}")
return file_contents
def update_script(script_path, corrected_code):
"""
Overwrites the script file with the corrected code.
Args:
script_path: Path to the script file.
corrected_code: The new code to write to the file.
"""
with open(script_path, "w") as f:
f.write(corrected_code)