taskbridgeapp.notes.model.note.Note
- class taskbridgeapp.notes.model.note.Note(name, created_date, modified_date, body_markdown='', body_html='', attachments=None, uuid=None)
Bases:
objectRepresents a note. Used to create notes from the local machine via a staged via or from the remote server from a Markdown file. Can also convert one type to the other.
Methods
Creates a Note instance from a staged file exported locally.
Creates a Note instance from an exported Markdown file.
Creates this note locally.
Converts a Note's body from Markdown to HTML.
Converts a Note's body from the HTML in a staged file to Markdown.
Updates this note locally.
Upserts the remote note.
- __init__(name, created_date, modified_date, body_markdown='', body_html='', attachments=None, uuid=None)
Create a new note.
- Parameters:
name (
str) – the name of the note. Added to first line of note when renderedcreated_date (<method ‘date’ of ‘datetime.datetime’ objects>) – creation date of the note
modified_date (<method ‘date’ of ‘datetime.datetime’ objects>) – modification date of the note (same as creation date in local)
body_markdown (
str) – the body of the note as markdownbody_html (
str) – the body of the note as htmlattachments (
List[Attachment]) – a list of attachments for this noteuuid (
str|None) – the UUID for this note
- static create_from_local(staged_content, staged_location)
Creates a Note instance from a staged file exported locally.
- Parameters:
staged_content (
str) – the content of the staged file.staged_location (
Path) – the location of the staged file, used for adding attachments to a/.attachmentsdir.
- Return type:
- Returns:
a Note instance representing the content of the staged file.
- static create_from_remote(remote_content, remote_location, remote_file_name)
Creates a Note instance from an exported Markdown file.
- Parameters:
remote_content (
str) – a list of strings from the remote Markdown content.remote_location (
Path) – the location of the remote note excluding file name.remote_file_name (
str) – the file name of the remote note excluding path.
- Return type:
- Returns:
a Note instance representing the content of the Markdown document.
- create_local(folder_name)
Creates this note locally.
- Parameters:
folder_name (
str) – the name of the folder where this note should be created.- Return type:
tuple[bool,str]- Returns:
-success (
bool) - true if the note is successfully created.-data (
str) - success message, or error message on failure.
- static markdown_to_html(remote_lines, attachments)
Converts a Note’s body from Markdown to HTML.
- Parameters:
remote_lines (
List[str]) – a list of Markdown lines.attachments (
List[Attachment]) – A list of Attachment associated with this note.
- Return type:
str- Returns:
an HTML representation of this note’s content.
- static staged_to_markdown(staged_lines, attachments, attachment_end)
Converts a Note’s body from the HTML in a staged file to Markdown.
- Parameters:
staged_lines (
List[str]) – a list of lines from the staged file.attachments (
List[Attachment]) – a list of Attachment associated with this note.attachment_end (
int) – the index of the line containing~~END ATTACHMENTS~~in the staged content.
- Return type:
str- Returns:
a Markdown representation of the note’s content.
- update_local(folder_name)
Updates this note locally.
- Parameters:
folder_name (
str) – the name of the folder where this note resides.- Return type:
tuple[bool,str]- Returns:
-success (
bool) - true if the note is successfully updated.-data (
str) - success message, or error message on failure.
- upsert_remote(remote_path)
Upserts the remote note.
- Parameters:
remote_path (
Path) – the path where the remote note resides, excluding the file name.- Return type:
tuple[bool,str]- Returns:
-success (
bool) - true if the note is successfully upserted.-data (
str) - success message, or error message on failure.