Version:

salvus.project.components.attachment_component

salvus.project.components.attachment_component salvus project components attachment_component
The attachment component for SalvusProject.
Allows one to attach any file up to a size limit in a Salvus project.

Classes

AttachmentComponent

Project subclass handling attachments to a project.
SIGNATURE
class AttachmentComponent(builtins.object):
    def __init__(self, project: Project, path: pathlib.Path): ...
ARGUMENTS
Required
project
Type:Project
Description:
The project.
Required
path
Type:pathlib.Path
Description:
Path to the attachment folder.

Methods

AttachmentComponent.add()
Add an attachment to the project.
SIGNATURE
def add(
    self,
    name: str,
    content: bytes | str | dict,
    overwrite: bool = False,
    description: str | None = None,
) -> None: ...
ARGUMENTS
Required
name
Type:str
Description:
Name of the file.
Required
content
Type:bytes | str | dict
Description:
Content of the file.
Optional
overwrite
Type:bool
Default value:False
Description:
Whether to overwrite the file if it already exists.
Optional
description
Type:str | None
Default value:None
Description:
An optional description of the file.
AttachmentComponent.delete()
Delete an attachment from disk and the project.
SIGNATURE
def delete(self, name: str) -> None: ...
ARGUMENTS
Required
name
Type:str
Description:
Name of the attachment to delete.
AttachmentComponent.detail_list()
List all attachments details.
Listed information is: - description; - size_in_bytes; - mime_type; - added_at.
SIGNATURE
def detail_list(self) -> builtins.list[dict]: ...
AttachmentComponent.get_content()
Get the content of an attachment as bytes.
SIGNATURE
def get_content(self, name: str) -> bytes: ...
ARGUMENTS
Required
name
Type:str
Description:
Name of the attachment.
AttachmentComponent.get_content_dict()
Get the content of an attachment as a dictionary.
Only a limited set of file types (json) can be retrieved as dictionaries.
SIGNATURE
def get_content_dict(self, name: str) -> dict: ...
ARGUMENTS
Required
name
Type:str
Description:
Name of the attachment.
AttachmentComponent.get_content_str()
Get the content of an attachment as a string.
Only a limited set of file types (plaintext, markdown) can be retrieved as strings.
SIGNATURE
def get_content_str(self, name: str) -> str: ...
ARGUMENTS
Required
name
Type:str
Description:
Name of the attachment.
AttachmentComponent.get_details()
Get details of an attachment.
SIGNATURE
def get_details(self, name: str) -> dict: ...
ARGUMENTS
Required
name
Type:str
Description:
Name of the attachment.
AttachmentComponent.list()
List all attachments.
SIGNATURE
def list(self) -> builtins.list[str]: ...
PAGE CONTENTS