trilium_alchemy.core.note.attachments¶
Class index¶
Canonical
Encapsulates an attachment, a named binary blob owned by a |
|
Interface to a note’s attachments, modeled as a list. |
Symbols¶
- class trilium_alchemy.core.note.attachments.Attachment(content: bytes | IO[bytes] | pathlib.Path | None = None, *, title: str | None = None, role: str = 'image', mime: str | None = None, session: Session | None = None, **kwargs)¶
Bases:
trilium_alchemy.core.entity.entity.OrderedEntityAliases:
trilium_alchemy.Attachment
trilium_alchemy.core.Attachment
trilium_alchemy.core.note.AttachmentEncapsulates an attachment, a named binary blob owned by a
Note.Trilium only supports image attachments.
Add to a note using its
Note.attachmentslist. An attachment can be created from rawbytes(requires atitle), apathlib.Path, or a binary file handle:note.attachments = [ Attachment(title="image.png", content=b"..."), Path("image.png"), open("image.png", "rb"), ]
- property note: Note¶
Getter for note which owns this attachment.
- Raises:
ValueError – If note has not been set
- property position: int¶
Getter for position of this attachment.
Note
This is maintained automatically based on the order of this attachment in its note’s
Note.attachmentslist.
- property state: State¶
Inherited from:
trilium_alchemy.core.entity.BaseEntityCurrent state.
- property session: Session¶
Inherited from:
trilium_alchemy.core.entity.BaseEntitySession to which this entity belongs.
- property str_short: str¶
Inherited from:
trilium_alchemy.core.entity.BaseEntityGet a short description of this entity.
- property str_summary: str¶
Inherited from:
trilium_alchemy.core.entity.BaseEntityGet a summary of this entity, including its current state and model values.
- save(path: str | pathlib.Path)¶
Write attachment content to the provided path.
- flush()¶
Inherited from:
trilium_alchemy.core.entity.BaseEntityCommit changes to Trilium for this entity and its dependencies.
- invalidate()¶
Inherited from:
trilium_alchemy.core.entity.BaseEntityDiscard cached contents and user-provided data for this object.
Upon next access, data will be fetched from Trilium.
- delete()¶
Inherited from:
trilium_alchemy.core.entity.BaseEntityMark this entity for pending delete.
- refresh()¶
Inherited from:
trilium_alchemy.core.entity.BaseEntityUpdate value from Trilium, discarding any local changes.
- class trilium_alchemy.core.note.attachments.Attachments(entity: BaseEntity)¶
Bases:
trilium_alchemy.core.note.extension.BaseEntityListInterface to a note’s attachments, modeled as a list.
Items assigned may be an
Attachment, apathlib.Path, or a binary file handle with a.name. Rawbytesis not accepted here since a title can’t be derived; construct anAttachmentexplicitly with a title instead.- append(value)¶
Inherited from:
collections.abc.MutableSequenceS.append(value) – append value to the end of the sequence
- clear()¶
Inherited from:
collections.abc.MutableSequenceS.clear() -> None – remove all items from S
- reverse()¶
Inherited from:
collections.abc.MutableSequenceS.reverse() – reverse IN PLACE
- extend(values)¶
Inherited from:
collections.abc.MutableSequenceS.extend(iterable) – extend sequence by appending elements from the iterable
- pop(index=-1)¶
Inherited from:
collections.abc.MutableSequenceS.pop([index]) -> item – remove and return item at index (default last). Raise IndexError if list is empty or index is out of range.
- remove(value)¶
Inherited from:
collections.abc.MutableSequenceS.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.
- index(value, start=0, stop=None)¶
Inherited from:
collections.abc.SequenceS.index(value, [start, [stop]]) -> integer – return first index of value. Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
- count(value)¶
Inherited from:
collections.abc.SequenceS.count(value) -> integer – return number of occurrences of value