WIP memory editor

This commit is contained in:
2024-11-23 21:36:50 +01:00
parent dbc0068a82
commit 2c820f6ead
15 changed files with 467 additions and 37 deletions

View File

@@ -15,14 +15,9 @@ class Entry(ABC):
Args:
id: Unique identifier for this entry
"""
self._id = id
self.id = id
self._change_handlers: List[Callable[['Entry'], None]] = []
@property
def id(self) -> str:
"""Get entry's unique identifier."""
return self._id
def add_change_handler(self, handler: Callable[['Entry'], None]) -> None:
"""Add a callback for entry changes."""
if handler not in self._change_handlers:

View File

@@ -135,7 +135,7 @@ class BackgroundEntry(Entry):
Returns:
ET.Element: XML element containing the entry's data
"""
element = ET.Element("background", {"id": self._id})
element = ET.Element("background", {"id": self.id})
if self._process is not None:
element.set("pid", str(self._process.pid))
elif self.exit_code is not None:
@@ -154,7 +154,7 @@ class BackgroundEntry(Entry):
"""
return {
"type": "background",
"id": self._id,
"id": self.id,
"script": self.script,
"stdout": self.stdout,
"stderr": self.stderr,

View File

@@ -116,5 +116,4 @@ class EntryFactory:
if "content" in data:
entry.content = data["content"]
if "written" in data:
entry.written = bool(data["written"])
entry.notify_change()
entry.written = bool(data["written"])

View File

@@ -35,7 +35,7 @@ class ParseErrorEntry(Entry):
Returns:
ET.Element: XML element containing the entry's data
"""
element = ET.Element("parse_error", {"id": self._id})
element = ET.Element("parse_error", {"id": self.id})
error_elem = ET.SubElement(element, "error")
error_elem.text = self.error
content_elem = ET.SubElement(element, "content")
@@ -49,7 +49,7 @@ class ParseErrorEntry(Entry):
"""
return {
"type": "parse_error",
"id": self._id,
"id": self.id,
"content": self.content,
"error": self.error,
}

View File

@@ -21,7 +21,7 @@ class ReadEntry(Entry):
io_buffer: Buffer to use for IO operations
"""
super().__init__(id)
self.content: str = "",
self.content: str = ""
self.read = False
self._io_buffer = io_buffer
@@ -42,7 +42,7 @@ class ReadEntry(Entry):
Returns:
ET.Element: XML element containing the entry's data
"""
element = ET.Element("read_stdin", {"id": self._id})
element = ET.Element("read_stdin", {"id": self.id})
if self.read:
element.text = self.content
@@ -54,7 +54,7 @@ class ReadEntry(Entry):
"""
return {
"type": "read_stdin",
"id": self._id,
"id": self.id,
"content": self.content,
"read": self.read,
}

View File

@@ -34,7 +34,7 @@ class ReasoningEntry(Entry):
Returns:
ET.Element: XML element containing the entry's data
"""
element = ET.Element("reasoning", {"id": self._id})
element = ET.Element("reasoning", {"id": self.id})
element.text = self.content
return element
@@ -45,6 +45,6 @@ class ReasoningEntry(Entry):
"""
return {
"type": "reasoning",
"id": self._id,
"id": self.id,
"content": self.content,
}

View File

@@ -32,9 +32,9 @@ class RepeatEntry(Entry):
self.script = script
self.timeout = timeout
self.limit = limit
self.stdout: str = "",
self.stderr: str = "",
self.exit_code: Optional[int] = None,
self.stdout: str = ""
self.stderr: str = ""
self.exit_code: Optional[int] = None
self.timed_out: bool = False
def update(self) -> None:

View File

@@ -32,10 +32,10 @@ class SingleEntry(Entry):
self.script = script
self.timeout = timeout
self.limit = limit
self.stdout: str = "",
self.stderr: str = "",
self.stdout: str = ""
self.stderr: str = ""
self.exit_code: Optional[int] = None
self.executed: bool = False,
self.executed: bool = False
self.timed_out: bool = False
def reset(self) -> None:
@@ -111,4 +111,6 @@ class SingleEntry(Entry):
"stdout": self.stdout,
"stderr": self.stderr,
"exit_code": self.exit_code,
"executed": self.executed,
"timed_out": self.timed_out
}

View File

@@ -54,6 +54,6 @@ class WriteEntry(Entry):
"""
return {
"type": "write",
"id": self._id,
"id": self.id,
"content": self.content,
}