smartinspectpython.sitextcontext

Module: sitextcontent.py

Revision History

Date Version Description
2023/05/30 3.0.0.0 Initial Version.

Is the base class for all viewer contexts which deal with text data. A viewer context is the library-side representation of a viewer in the Console.

Threadsafety:

This class is not guaranteed to be thread-safe.

Initializes a new instance of the class.

Arguments:
  • vi (SIViewerId): The viewer ID to use.
ViewerData: _io.BytesIO

Overridden. Returns the actual data which will be displayed in the viewer specified by the viewer id.

def AppendLine(self, line: str) -> None:

Appends a line to the text data.

Arguments:
  • line (str): The line to append.
Raises:
  • SIArgumentNullException: The line argument is null.

This method appends the supplied line and a carriage return

  • linefeed character to the internal text data after it has been escaped by the EscapeLine method.
def AppendText(self, text: str) -> None:

Appends text.

Arguments:
  • Text (str): The text to append.
Raises:
  • SIArgumentNullException: The text argument is null.
def Dispose(self, disposing: bool) -> None:

Releases any resources.

Arguments:
  • disposing (bool): True if managed resources should be released and false otherwise.
def EscapeLine(self, line: str) -> str:

Escapes a line.

Arguments:
  • line (str): The line to escape.
Returns:

The escaped line.

If overridden in derived classes, this method escapes a line depending on the viewer format used. The default implementation does no escaping.

def LoadFromFile(self, fileName: str) -> None:

Loads the text from a file.

Arguments:
  • (str): The name of the file to load the text from.
Raises:
  • SIArgumentNullException: The filename argument is null.
  • IOException: An I/O error occurred.
def LoadFromReader(self, reader: _io.TextIOWrapper) -> None:

Loads the text from a reader.

Arguments:
  • reader (TextIOWrapper): The reader to read the text from.
Raises:
  • SIArgumentNullException: The reader argument is null.
  • IOException: An I/O error occurred.

If the supplied text reader supports seeking then the entire text reader content will be read and the stream position will be restored correctly. Otherwise the data will be read from the current position to the end and the original position can not be restored.

def LoadFromStream(self, stream: _io.TextIOWrapper) -> None:

Loads the text from a stream.

Arguments:
  • stream (TextIOWrapper): The stream to load the text from.
Raises:
  • SIArgumentNullException: The stream argument is null.
  • IOException: An I/O error occurred.

If the supplied stream supports seeking then the entire stream content will be read and the stream position will be restored correctly. Otherwise the data will be read from the current position to the end and the original position can not be restored.

def LoadFromText(self, text: str) -> None:

Loads the text.

Arguments:
  • Text (str): The text to load.
Raises:
  • SIArgumentNullException: The text argument is null.
def ResetData(self) -> None:

Resets the internal data.

This method is intended to reset the internal text data if custom handling of data is needed by derived classes.