-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcode_editor.py
More file actions
27 lines (22 loc) · 855 Bytes
/
code_editor.py
File metadata and controls
27 lines (22 loc) · 855 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
import os
from git import Repo
class CodeEditor:
def __init__(self):
self.generatedCode = {}
def display_code(self, project_name):
if project_name in self.generatedCode:
return self.generatedCode[project_name]
else:
return "No code generated for this project yet."
def commit_changes(self, project_name, commit_message):
if project_name in self.generatedCode:
repo = Repo(os.getcwd())
repo.git.add(update=True)
repo.index.commit(commit_message)
return "Changes committed successfully."
else:
return "No code generated for this project yet."
def update_code(self, project_name, new_code):
self.generatedCode[project_name] = new_code
return "Code updated successfully."
code_editor = CodeEditor()