Private instance vars, public get properties
This commit is contained in:
@@ -9,8 +9,8 @@ class ReadEntry(Entry):
|
||||
Entry type for reading content from standard input.
|
||||
|
||||
Attributes:
|
||||
content: Content read from stdin, empty until first update
|
||||
io_buffer: Buffer to use for IO operations
|
||||
_content: Content read from stdin, empty until first update
|
||||
_io_buffer: Buffer to use for IO operations
|
||||
_read: Whether content has been read
|
||||
"""
|
||||
|
||||
@@ -24,9 +24,16 @@ class ReadEntry(Entry):
|
||||
timestamp: Creation timestamp for this entry
|
||||
"""
|
||||
super().__init__(id, timestamp)
|
||||
self.content = ""
|
||||
self.io_buffer = io_buffer
|
||||
self._content = ""
|
||||
self._io_buffer = io_buffer
|
||||
self._read = False
|
||||
|
||||
@property
|
||||
def content(self) -> str:
|
||||
"""
|
||||
Get the content read from stdin.
|
||||
"""
|
||||
return self._content
|
||||
|
||||
def update(self) -> None:
|
||||
"""
|
||||
@@ -34,7 +41,7 @@ class ReadEntry(Entry):
|
||||
Uses the provided IO buffer for the actual read operation.
|
||||
"""
|
||||
if not self._read:
|
||||
self.content = self.io_buffer.read()
|
||||
self._content = self._io_buffer.read()
|
||||
self._read = True
|
||||
|
||||
def generate_context(self) -> ET.Element:
|
||||
@@ -45,10 +52,10 @@ class ReadEntry(Entry):
|
||||
ET.Element: XML element containing the entry's data
|
||||
"""
|
||||
# Create root element
|
||||
element = ET.Element("read_stdin", {"id": self.id})
|
||||
element = ET.Element("read_stdin", {"id": self._id})
|
||||
|
||||
# Add content as CDATA or escaped text if content has been read
|
||||
if self._read:
|
||||
element.text = escape_text_for_xml(self.content)
|
||||
element.text = escape_text_for_xml(self._content)
|
||||
|
||||
return element
|
||||
Reference in New Issue
Block a user