Fixed stdin buffer length in context
This commit is contained in:
@@ -7,8 +7,9 @@ from .command import Command
|
||||
from .delete_command import DeleteCommand
|
||||
from .stop_command import StopCommand
|
||||
|
||||
from .entry import Entry
|
||||
from .background_entry import BackgroundEntry
|
||||
from .entry import Entry
|
||||
from .io_buffer import IOBuffer
|
||||
from .parse_error_entry import ParseErrorEntry
|
||||
from .read_entry import ReadEntry
|
||||
from .reasoning_entry import ReasoningEntry
|
||||
@@ -28,14 +29,24 @@ class ResponseParser:
|
||||
io_buffer: Buffer to use for IO operations
|
||||
"""
|
||||
|
||||
def __init__(self, io_buffer):
|
||||
def __init__(self, io_buffer: IOBuffer):
|
||||
"""
|
||||
Initialize parser with IO buffer.
|
||||
|
||||
Args:
|
||||
io_buffer: Buffer to use for IO operations
|
||||
"""
|
||||
self.io_buffer = io_buffer
|
||||
self._io_buffer = io_buffer
|
||||
|
||||
@property
|
||||
def io_buffer(self) -> IOBuffer:
|
||||
"""
|
||||
Get the IO buffer used by the parser.
|
||||
|
||||
Returns:
|
||||
IOBuffer: Buffer used for IO operations
|
||||
"""
|
||||
return self._io_buffer
|
||||
|
||||
def parse(self, xml: str) -> Union[Command, Entry]:
|
||||
"""
|
||||
@@ -101,12 +112,12 @@ class ResponseParser:
|
||||
return ReasoningEntry(entry_id, timestamp, root.text)
|
||||
|
||||
elif root.tag == 'read_stdin':
|
||||
return ReadEntry(entry_id, timestamp, self.io_buffer)
|
||||
return ReadEntry(entry_id, timestamp, self._io_buffer)
|
||||
|
||||
elif root.tag == 'write_stdout':
|
||||
if len(root) != 0 or root.attrib or root.text is None or root.text.strip() == '':
|
||||
return ParseErrorEntry(entry_id, timestamp, xml, "Write stdout entry requires (only) text content")
|
||||
return WriteEntry(entry_id, timestamp, root.text, self.io_buffer)
|
||||
return WriteEntry(entry_id, timestamp, root.text, self._io_buffer)
|
||||
|
||||
else:
|
||||
return ParseErrorEntry(entry_id, timestamp, xml, f"Unknown root element: {root.tag}")
|
||||
|
||||
Reference in New Issue
Block a user