Private instance vars, public get properties

This commit is contained in:
2024-11-01 15:45:54 +01:00
parent d80171de15
commit a95c9676b4
18 changed files with 429 additions and 427 deletions

View File

@@ -7,10 +7,6 @@ from .util import escape_text_for_xml
class ParseErrorEntry(Entry):
"""
Entry type for parse and validation errors.
Attributes:
content: The original content that failed to parse
error: The error message describing what went wrong
"""
def __init__(self, content: str, error: str, id: str, timestamp: datetime):
@@ -24,11 +20,20 @@ class ParseErrorEntry(Entry):
timestamp: Creation timestamp for this entry
"""
super().__init__(id, timestamp)
self.content = content
self.error = error
self._content = content
self._error = error
@property
def content(self) -> str:
"""Get the original content that failed to parse."""
return self._content
@property
def error(self) -> str:
"""Get the error message describing the failure."""
return self._error
def update(self) -> None:
"""No update needed for parse error entries."""
pass
def generate_context(self) -> ET.Element:
@@ -39,14 +44,14 @@ class ParseErrorEntry(Entry):
ET.Element: XML element containing the entry's data
"""
# Create root element
element = ET.Element("parse_error", {"id": self.id})
element = ET.Element("parse_error", {"id": self._id})
# Add error subelement
error_elem = ET.SubElement(element, "error")
error_elem.text = escape_text_for_xml(self.error)
error_elem.text = escape_text_for_xml(self._error)
# Add content subelement
content_elem = ET.SubElement(element, "content")
content_elem.text = escape_text_for_xml(self.content)
content_elem.text = escape_text_for_xml(self._content)
return element