This commit is contained in:
2024-12-04 17:19:46 +01:00
parent af390dd779
commit da8583ab28
36 changed files with 712 additions and 69 deletions

View File

@@ -1,4 +1,5 @@
from datetime import datetime
from pathlib import Path
import xml.etree.ElementTree as ET
from typing import Union
@@ -30,13 +31,15 @@ class ResponseParser:
io_buffer: Buffer to use for IO operations
"""
def __init__(self, io_buffer: IOBuffer):
def __init__(self, work_dir: Path, io_buffer: IOBuffer):
"""
Initialize parser with IO buffer.
Args:
work_dir: Workdir for the scripts
io_buffer: Buffer to use for IO operations
"""
self._work_dir = work_dir
self._io_buffer = io_buffer
@property
@@ -87,7 +90,7 @@ class ResponseParser:
elif root.tag == 'background':
if len(root) != 0 or root.attrib or root.text is None or root.text.strip() == '':
return ParseErrorEntry(entry_id, xml, "Background entry requires (only) script content")
return BackgroundEntry(entry_id, root.text)
return BackgroundEntry(entry_id, self._work_dir, root.text)
elif root.tag == 'repeat':
if len(root) != 0 or root.text is None or root.text.strip() == '':
@@ -98,7 +101,7 @@ class ResponseParser:
limit = root.get('limit')
timeout = float(timeout) if timeout is not None else None
limit = int(limit) if limit is not None else None
return RepeatEntry(entry_id, root.text, timeout, limit)
return RepeatEntry(entry_id, self._work_dir, root.text, timeout, limit)
elif root.tag == 'single':
if len(root) != 0 or root.text is None or root.text.strip() == '':
@@ -109,7 +112,7 @@ class ResponseParser:
limit = root.get('limit')
timeout = float(timeout) if timeout is not None else None
limit = int(limit) if limit is not None else None
return SingleEntry(entry_id, root.text, timeout, limit)
return SingleEntry(entry_id, self._work_dir, root.text, timeout, limit)
elif root.tag == 'reasoning':
if len(root) != 0 or root.attrib or root.text is None or root.text.strip() == '':