Skip to content

pixano.features.schemas.views.text

Text(created_at=None, updated_at=None, **data)

Bases: View

Text view.

Attributes:

Name Type Description
content str

The text content.

Source code in pixano/features/schemas/base_schema.py
def __init__(self, /, created_at: datetime | None = None, updated_at: datetime | None = None, **data: Any):
    """Create a new model by parsing and validating input data from keyword arguments.

    Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be
    validated to form a valid model.

    `self` is explicitly positional-only to allow `self` as a field name.

    Args:
        created_at: The creation date of the object.
        updated_at: The last modification date of the object.
        data: The data of the object validated by Pydantic.
    """
    created_at, updated_at = validate_and_init_create_at_and_update_at(created_at, updated_at)
    data.update({"created_at": created_at, "updated_at": updated_at})
    super().__init__(**data)

create_text(content, id='', item_ref=ItemRef.none(), parent_ref=ViewRef.none())

Create a Text instance.

Parameters:

Name Type Description Default
content str

The text content.

required
id str

Text ID.

''
item_ref ItemRef

Item reference.

none()
parent_ref ViewRef

Parent view reference.

none()

Returns:

Type Description
Text

The created Text instance.

Source code in pixano/features/schemas/views/text.py
def create_text(
    content: str,
    id: str = "",
    item_ref: ItemRef = ItemRef.none(),
    parent_ref: ViewRef = ViewRef.none(),
) -> Text:
    """Create a `Text` instance.

    Args:
        content: The text content.
        id: Text ID.
        item_ref: Item reference.
        parent_ref: Parent view reference.

    Returns:
        The created `Text` instance.
    """
    return Text(id=id, item_ref=item_ref, parent_ref=parent_ref, content=content)

is_text(cls, strict=False)

Check if the given class is Text or a subclass of Text.

Source code in pixano/features/schemas/views/text.py
def is_text(cls: type, strict: bool = False) -> bool:
    """Check if the given class is `Text` or a subclass of `Text`."""
    return issubclass_strict(cls, Text, strict)