-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupdater.py
More file actions
36 lines (29 loc) · 889 Bytes
/
updater.py
File metadata and controls
36 lines (29 loc) · 889 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
30
31
32
33
34
35
from openai_test import tester
# Takes in the error from the code and pulls out the file
def pullFile(error:str)->str:
words = error.split(" ")
file = ""
i = 0
while(i<len(words)):
print(words[i])
if words[i] == "line":
file = words[i-1]
if "\n" in file:
file = file.split("\n")[-1]
file = file.rstrip(''','"''')
file = "output" + file
return file
i+=1
return file
def file_updater(chat:str, fileLocation:str):
start_i = chat.find("```python")+9
end_i = chat.rfind("```")
updated_text = chat[start_i: end_i]
with open(fileLocation, "w") as file:
file.write(updated_text)
def updater(error:str):
try:
file = pullFile(error)
file_updater(tester(file, error), file)
except Exception as ex:
print(ex)