labapi.entry.entries.text.TextEntry#

class labapi.entry.entries.text.TextEntry(eid: str, data: str, user: User)[source]#

Bases: PlainTextEntry

Represents a rich text entry on a LabArchives page.

This class is used for entries containing formatted text, typically HTML.

__init__(eid: str, data: str, user: User)#

Initialize a plain-text entry.

Parameters:
  • eid – The unique ID of the entry.

  • data – The text content of the entry.

  • user – The authenticated user.

Methods

__init__(eid, data, user)

Initialize a plain-text entry.

class_of(part_type)

Return the registered entry class for part_type.

from_part_type(part_type, eid, data, user)

Create an entry instance for a LabArchives part type.

is_registered(part_type)

Return whether an entry class is registered for part_type.

Attributes

content

Return the entry text.

content_type

Return the LabArchives content type identifier for this entry.

id

Return the unique identifier of the entry.

static class_of(
part_type: str,
) Type[Entry[Any]]#

Return the registered entry class for part_type.

Parameters:

part_type – The LabArchives part type identifier.

Returns:

The Entry subclass registered for this part type.

Raises:

KeyError – If no class is registered for the specified part type.

property content: str#

Return the entry text.

Returns:

The content of the entry as a string.

property content_type: str#

Return the LabArchives content type identifier for this entry.

Returns:

A string representing the entry’s type (e.g., “text entry”, “Attachment”).

static from_part_type(
part_type: str,
eid: str,
data: str,
user: User,
) Entry[Any]#

Create an entry instance for a LabArchives part type.

This method takes a part type string and returns the corresponding entry class instance. The part type is normalized before matching.

Parameters:
  • part_type – The type of entry to create (e.g., “heading”, “text entry”, “plain text entry”, “attachment”, “widget entry”).

  • eid – The unique ID of the entry.

  • data – The entry data. For text-based entries, this is the text content. For attachment entries, this is the caption.

  • user – The authenticated user associated with this entry.

Returns:

An entry instance of the appropriate type.

Raises:

NotImplementedError – If the part type is not recognized or implemented.

property id#

Return the unique identifier of the entry.

Returns:

The entry’s ID as a string.

static is_registered(part_type: str) bool#

Return whether an entry class is registered for part_type.

Parameters:

part_type – The LabArchives part type identifier to check.

Returns:

True if a class is registered for this part type, False otherwise.