Tachi67 commited on
Commit
3a0244e
·
1 Parent(s): fa38016

Update CodeFileEditAtomicFlow.py

Browse files
Files changed (1) hide show
  1. CodeFileEditAtomicFlow.py +3 -12
CodeFileEditAtomicFlow.py CHANGED
@@ -30,12 +30,11 @@ class CodeFileEditAtomicFlow(AtomicFlow):
30
  try:
31
  with open(file_location, "w") as file:
32
  file.write(content)
33
- file_written_timestamp = os.path.getmtime(file_location)
34
 
35
- return True, f"Code written to {file_location}", file_location, file_written_timestamp
36
 
37
  except Exception as e:
38
- return False, str(e), file_location, 0
39
 
40
  def _check_input(self, input_data: Dict[str, Any]):
41
  assert "code" in input_data, "code is not passed to CodeFileEditAtomicFlow"
@@ -65,19 +64,11 @@ class CodeFileEditAtomicFlow(AtomicFlow):
65
  content_to_write, file_location_to_write = self._generate_input_to_writer(input_data)
66
 
67
  # ~~~ Calling the writer function ~~~
68
- result, code_editor_output, temp_file_location, file_written_timestamp = self._write_code_content_to_file(
69
  file_location_to_write, content_to_write)
70
 
71
- # ~~~ Opening up the file for the user to see ~~~
72
- if result:
73
- try:
74
- subprocess.run(["code", temp_file_location], timeout=10)
75
- except (subprocess.CalledProcessError, subprocess.TimeoutExpired):
76
- webbrowser.open(temp_file_location)
77
-
78
  # ~~~ Generating return variables ~~~
79
  response = {}
80
  response["code_editor_output"] = code_editor_output
81
  response["temp_code_file_location"] = temp_file_location
82
- response["temp_code_file_written_timestamp"] = file_written_timestamp
83
  return response
 
30
  try:
31
  with open(file_location, "w") as file:
32
  file.write(content)
 
33
 
34
+ return True, f"Code written to {file_location}", file_location
35
 
36
  except Exception as e:
37
+ return False, str(e), file_location
38
 
39
  def _check_input(self, input_data: Dict[str, Any]):
40
  assert "code" in input_data, "code is not passed to CodeFileEditAtomicFlow"
 
64
  content_to_write, file_location_to_write = self._generate_input_to_writer(input_data)
65
 
66
  # ~~~ Calling the writer function ~~~
67
+ result, code_editor_output, temp_file_location = self._write_code_content_to_file(
68
  file_location_to_write, content_to_write)
69
 
 
 
 
 
 
 
 
70
  # ~~~ Generating return variables ~~~
71
  response = {}
72
  response["code_editor_output"] = code_editor_output
73
  response["temp_code_file_location"] = temp_file_location
 
74
  return response