taskbridgeapp.reminders.model.remindercontainer.ReminderContainer
- class taskbridgeapp.reminders.model.remindercontainer.ReminderContainer(local_list, remote_calendar, sync)
Bases:
objectRepresents a folder or calendar containing reminders. A link is established here between the local list and the remote calendar. Also contains a list of the reminders in this container, both local and remote.
Methods
Associate local reminder lists with remote lists.
Associate remote reminder lists with local lists.
Counts the number of completed reminders.
Creates an association between local reminder lists and remote task calendars.
Deletes completed reminders.
Get the list of saved reminders from the database.
Loads the list of CalDav calendars which support VTODO components (i.e. task calendars).
Load the list of local reminder lists.
Load the list of local reminders in this local container (list) via an AppleScript script.
Load the list of remote reminders (tasks) in this remote container (calendar) via CalDav.
Save the list of containers to SQLite.
Save the list of reminders to SQLite.
Creates the initial structure for the table storing containers in SQLite.
Creates the initial structure for the table storing reminders in SQLite.
Synchronises deletions to reminder containers.
Sync local reminders to remote tasks.
Synchronises deletions to reminders.
Synchronises reminders.
Sync remote tasks to local reminders.
Attributes
List of all found reminder containers
-
CONTAINER_LIST:
List[ReminderContainer] = [] List of all found reminder containers
- __empty_reminder_table(fail)
Empties the reminder table
- Parameters:
fail (
str) – the part of the process to intentionally fail (used for test coverage).- Return type:
tuple[bool,str]- Returns:
-success (
bool) - true if reminder table is successfully emptied.-data (
str) - error message on failure or success message.
- __get_current_reminders(container, fail)
Get the current local and remote reminders for this container
- Parameters:
container (
ReminderContainer) – the container to fetch reminders for.fail (
str) – the part of the process to intentionally fail (used for test coverage).
- Return type:
tuple[bool,str]- Returns:
-success (
bool) - true if both local and remote reminders are loaded successfully.-data (
str) - error message on failure or success message.
- __init__(local_list, remote_calendar, sync)
Create a new reminder container.
- Parameters:
local_list (
LocalList|None) – the local list containing the local reminders.remote_calendar (
RemoteCalendar|None) – the remote calendar containing the remote tasks.sync (
bool) – True if the local list and remote calendar should be synchronised.
- static _delete_local_containers(removed_remote_containers, removed_local_containers, discovered_local, to_sync, result, fail=False)
Deletes remote reminder containers which have been deleted locally.
- Parameters:
removed_remote_containers (
List[Row]) – list of containers which have been deleted remotely.removed_local_containers (
List[Row]) – list of containers which have been deleted locally.discovered_local (
List[LocalList]) – the list of local reminder lists.to_sync (
List[str]) – the list of lists/calendars which should be synchronised.result (
dict) – dictionary where changes are appendedfail (
bool) – method will fail if this is True (used for test coverage)
- Return type:
tuple[bool,str]- Returns:
-success (
bool) - true if container deletions are successfully carried out.-data (
str) - error message on failure or success message.
- static _delete_local_reminders(container_saved_remote, container, result, fail=False)
Delete local reminders which have been deleted remotely.
- Parameters:
container_saved_remote (
List[Row]) – list of reminders from last sync.container (
ReminderContainer) – the reminder container.result (
dict) – dictionary where changes are appended.fail (
bool) – deletion will fail if this is true (used for test coverage).
- Return type:
tuple[bool,str]- Returns:
-success (
bool) - true if reminder deletions are successfully synchronised.-data (
str) - error message on failure or success message.
- static _delete_remote_containers(removed_local_containers, discovered_remote, to_sync, result, fail=False)
Deletes remote reminder containers which have been deleted locally.
- Parameters:
removed_local_containers (
List[Row]) – list of containers which have been deleted locally.discovered_remote (
List[RemoteCalendar]) – the list of remote task calendars.to_sync (
List[str]) – the list of lists/calendars which should be synchronised.result (
dict) – dictionary where changes are appendedfail (
bool) – method will fail if this is True (used for test coverage)
- Return type:
tuple[bool,str]- Returns:
-success (
bool) - true if container deletions are successfully carried out.-data (
str) - error message on failure or success message.
- static _delete_remote_reminders(container_saved_local, container, result)
Delete remote reminders which have been deleted locally.
- Parameters:
container_saved_local (
List[Row]) – list of reminders from last sync.container (
ReminderContainer) – the reminder containerresult (
dict) – dictionary where changes are appended
- Return type:
tuple[bool,str]- Returns:
-success (
bool) - true if reminder deletions are successfully synchronised.-data (
str) - error message on failure or success message.
- static assoc_list_local_remote(local_lists, remote_calendars, to_sync)
Associate local reminder lists with remote lists.
- Parameters:
local_lists (
List[LocalList]) – discovered local listsremote_calendars (
List[RemoteCalendar]) – discovered remote calendarsto_sync (
List[str]) – list of containers to keep in sync
- Return type:
tuple[bool,str]- Returns:
-success (
bool) - true if the containers are successfully linked.-data (
str) - error message on failure, or success message.
- static assoc_list_remote_local(local_lists, remote_calendars, to_sync, fail=False)
Associate remote reminder lists with local lists.
- Parameters:
local_lists (
List[LocalList]) – discovered local listsremote_calendars (
List[RemoteCalendar]) – discovered remote calendarsto_sync (
List[str]) – list of containers to keep in syncfail (
bool) – set this to True to fail this task (used for test coverage)
- Return type:
tuple[bool,str]- Returns:
-success (
bool) - true if the containers are successfully linked.-data (
str) - error message on failure, or success message.
- static count_local_completed(fail=False)
Counts the number of completed reminders.
- Parameters:
fail (
bool) – if set to True, this method fails on purpose (used for test coverage)- Return type:
tuple[bool,str] |tuple[bool,int]- Returns:
-success (
bool) - true if the number of completed reminders is successfully retrieved-data (
str| :py:class`int`) - error message or number of completed reminders.
- static create_linked_containers(local_lists, remote_calendars, to_sync)
Creates an association between local reminder lists and remote task calendars. Missing containers are created; for example, if the list foo is present locally, and
syncis set to True, this method will check if the remote calendar foo exists and, if not, creates it.The list of containers is saved to an SQLite database.
Important: The local list ‘Reminders’ is ALWAYS associated with the remote calendar ‘Tasks’.
- Parameters:
local_lists (
List[LocalList]) – list of local reminder lists.remote_calendars (
List[RemoteCalendar]) – list of remote task calendars.to_sync (
List[str]) – list of reminder/task lists/calendars to synchronise. Sync is always bidirectional.
- Return type:
tuple[bool,str]- Returns:
-success (
bool) - true if the containers are successfully linked.-data (
str) - error message on fail, or success message.
- static delete_local_completed()
Deletes completed reminders. This is important, as too many reminders can cause synchronisation to be very slow.
- Return type:
tuple[bool,str]- Returns:
-success (
bool) - true if completed reminders are successfully deleted-data (
str) - error message or fail, or success message.
- static get_saved_reminders()
Get the list of saved reminders from the database.
- Return type:
tuple[bool,str] |tuple[bool,List[Row]]- Returns:
-success (
bool) - true if database reminders are successfully loaded-data (
str|dict) - error message on failure or list of saved reminders.
- static load_caldav_calendars()
Loads the list of CalDav calendars which support VTODO components (i.e. task calendars).
- Return type:
tuple[bool,str] |tuple[bool,List[RemoteCalendar]]- Returns:
-success (
bool) - true if the list of remote calendars is successfully loaded.-data (
str| :py:class`List[RemoteCalendar]`) - error message on failure or list of remote calendars.
- static load_local_lists(fail=False)
Load the list of local reminder lists.
- Parameters:
fail (
bool) – if set to True, this method fails on purpose (used for test coverage)- Return type:
tuple[bool,str] |tuple[bool,List[LocalList]]- Returns:
-success (
bool) - true if the list of local reminder lists is successfully loaded.-data (
str| :py:class`List[LocalList]`) - error message on failure or list of local reminder lists.
- load_local_reminders(fail=None)
Load the list of local reminders in this local container (list) via an AppleScript script. The reminders are saved in a pipe-separated .psv file in a temporary folder, and then parsed from there.
- Parameters:
fail (
str) – the part of the process to intentionally fail (used for test coverage)- Return type:
tuple[bool,str] |tuple[bool,int]- Returns:
-success (
bool) - true if the reminders are successfully loaded.-data (
str|int) - error message on failure or number of loaded reminders on success.
- load_remote_reminders()
Load the list of remote reminders (tasks) in this remote container (calendar) via CalDav.
- Return type:
tuple[bool,str] |tuple[bool,int]- Returns:
-success (
bool) - true if the reminders are successfully loaded.-data (
str|int) - error message on failure or number of loaded reminders on success.
- static persist_containers()
Save the list of containers to SQLite.
- Return type:
tuple[bool,str]- Returns:
-success (
bool) - true if the containers are successfully saved.-data (
str) - error message on failure or success message.
- static persist_reminders()
Save the list of reminders to SQLite. Due to the fact that local reminder UUIDs are read-only, this list may contain reminders without an associated remote UID. For this reason, the reminder’s summary (which is typically the only text content) has to be saved to the database. Without this, many reminders couldn’t be matched. The database is stored locally.
- Return type:
tuple[bool,str]- Returns:
-success (
bool) - true if the reminders as successfully saved.-data (
str) - error message on failure or success message.
- static seed_container_table()
Creates the initial structure for the table storing containers in SQLite.
- Return type:
tuple[bool,str]- Returns:
-success (
bool) - true if the table is successfully seeded.-data (
str) - error message on failure or success message.
- static seed_reminder_table()
Creates the initial structure for the table storing reminders in SQLite.
- Return type:
tuple[bool,str]- Returns:
-success (
bool) - true if the table is successfully seeded.-data (
str) - error message on failure or success message.
- static sync_container_deletions(discovered_local, discovered_remote, to_sync, fail=None)
Synchronises deletions to reminder containers.
The list of containers found during the last sync is loaded from SQLite and compared to the local and remote lists found now. Any lists in the database which are no longer present will have their counterpart deleted. For example, if the local list foo is deleted, the remote calendar foo will be deleted during sync.
Note that container deletions only apply if the list/calendar is found in the
to_syncargument.On success, this method returns a dictionary with changes, containing the following keys:
updated_local_list- the list of local reminder lists, taking into account deleted lists.updated_remote_list- the list of remote task calendars, taking into account deleted calendars.
- Parameters:
discovered_local (
List[LocalList]) – the list of local reminder lists.discovered_remote (
List[RemoteCalendar]) – the list of remote task calendars.to_sync (
List[str]) – the list of lists/calendars which should be synchronised.fail (
str) – the part of the process to intentionally fail (used for test coverage)
- Return type:
tuple[bool,str] |tuple[bool,dict]- Returns:
-success (
bool) - true if container deletions are successfully synchronised.-data (
str|dict) - error message on failure or result as above on success.
- sync_local_reminders_to_remote(result, fail=None)
Sync local reminders to remote tasks.
- Parameters:
result (
dict) – dictionary where actions are appendedfail (
str) – the part of the process to intentionally fail (used for test coverage)
- Return type:
tuple[bool,str]- Returns:
-success (
bool) - true if the reminders are successfully synchronised.-data (
str) - error message on failure or success message.
- static sync_reminder_deletions(fail=None)
Synchronises deletions to reminders.
The list of reminders found during the last sync is loaded from SQLite and compared to the local and remote reminders found now. Any reminders in the database which are no longer present will have their counterpart deleted. For example, if the local reminder foo is deleted, the remote reminder foo will be deleted during sync.
Note that reminder deletion only applies to those containers with
syncset to True.On success, this method returns a dictionary with changes, containing the following keys:
deleted_local_reminders- a list of local reminders deleted asList[Reminder].deleted_remote_reminders- a list of remote tasks deleted asList[Reminder].
A reminder not being found is not considered an error, as the user may have deleted the reminder manually prior to the sync running.
- Parameters:
fail (
str) – the part of the process to intentionally fail (used for test coverage)- Return type:
tuple[bool,str] |tuple[bool,dict]- Returns:
-success (
bool) - true if reminder deletions are successfully synchronised.-data (
str|dict) - error message on failure or result as above on success.
- sync_reminders(fail=None)
Synchronises reminders. This method only synchronises reminders for containers with
syncset to True. On success, the method returns a dictionary with the following keys:remote_added- name of reminders added to the remote calendar asList[str].remote_updated- name of reminders updated in the remote calendar asList[str].local_added- name of reminders added to the local list asList[str].local_updated- name of reminders updated in the local list asList[str].
Any of the above may be empty if no changes were made.
- Parameters:
fail (
str) – the part of the process to intentionally fail (used for test coverage)- Return type:
tuple[bool,str] |tuple[bool,dict]- Returns:
-success (
bool) - true if the reminders are successfully synchronised.-data (
str|dict) - error message on failure ordictwith results as above.
- sync_remote_reminders_to_local(result, fail=None)
Sync remote tasks to local reminders.
- Parameters:
result (
dict) – dictionary where actions are appendedfail (
str) – the part of the process to intentionally fail (used for test coverage)
- Return type:
tuple[bool,str]- Returns:
-success (
bool) - true if the reminders are successfully synchronised.-data (
str) - error message on failure or success message.
-
CONTAINER_LIST: