collaboration.databasesync module¶
Class |
Description |
|---|---|
Add a snapshot to the id map in a database |
|
Get the default filepath for a remote File. This is based off the Setting for collaboration.direc… |
|
Get the default directory path for a remote Project. This is based off the Setting for… |
|
Download a file from its remote, saving all snapshots to a database in the specified location. |
|
Print debug information about a database to stdout |
|
|
Get the local snapshot associated with a remote snapshot (if it exists) |
|
Get the Remote File for a Database |
|
Get the Remote for a Database |
|
Get the Remote Project for a Database |
|
Get the remote snapshot associated with a local snapshot (if it exists) |
Get the remote author of a local snapshot |
|
Ignore a snapshot from database syncing operations |
|
|
Test if a database is valid for use in collaboration |
Test if a snapshot is ignored from the database |
|
Merge all leaf snapshots in a database down to a single leaf snapshot. |
|
Pull updated snapshots from the remote. Merge local changes with remote changes and potentially… |
|
Push locally added snapshots to the remote |
|
Set the remote author of a local snapshot (does not upload) |
|
Completely sync a database, pushing/pulling/merging/applying changes |
|
Upload a file, with database, to the remote under the given project |
assign_snapshot_map¶
- class assign_snapshot_map[source]¶
Bases:
Add a snapshot to the id map in a database
- Parameters:
local_snapshot – Local snapshot, will use this snapshot’s database
remote_snapshot – Remote snapshot
- Raises:
RuntimeError – If there was an error
default_file_path¶
- class default_file_path[source]¶
Bases:
Get the default filepath for a remote File. This is based off the Setting for collaboration.directory, the file’s id, the file’s project’s id, and the file’s remote’s id.
- Parameters:
file – Remote File
- Returns:
Default file path
- Raises:
RuntimeError – If there was an error
default_project_path¶
- class default_project_path[source]¶
Bases:
Get the default directory path for a remote Project. This is based off the Setting for collaboration.directory, the project’s id, and the project’s remote’s id.
- Parameters:
project – Remote Project
- Returns:
Default project path
- Raises:
RuntimeError – If there was an error
download_file¶
- class download_file[source]¶
Bases:
Download a file from its remote, saving all snapshots to a database in the specified location. Returns a FileContext for opening the file later.
- Parameters:
file – Remote File to download and open
db_path – File path for saved database
progress – Function to call for progress updates
- Returns:
FileContext for opening
- Raises:
RuntimeError – If there was an error
dump_database¶
- class dump_database[source]¶
Bases:
Print debug information about a database to stdout
- Parameters:
database – Database to dump
- Raises:
RuntimeError – If there was an error
get_local_snapshot_for_remote¶
- class get_local_snapshot_for_remote[source]¶
Bases:
Get the local snapshot associated with a remote snapshot (if it exists)
- Parameters:
snapshot – Remote snapshot
database – Local database to search
- Returns:
Snapshot reference if it exists, or None reference if not
- Raises:
RuntimeError – If there was an error
get_remote_file_for_local_database¶
- class get_remote_file_for_local_database[source]¶
Bases:
Get the Remote File for a Database
- Parameters:
database – BN database, potentially with collaboration metadata
- Returns:
Remote file from one of the connected remotes, or None if not found or if files are not pulled
- Raises:
RuntimeError – If there was an error
get_remote_for_local_database¶
- class get_remote_for_local_database[source]¶
Bases:
Get the Remote for a Database
- Parameters:
database – BN database, potentially with collaboration metadata
- Returns:
Remote from one of the connected remotes, or None if not found
- Raises:
RuntimeError – If there was an error
get_remote_project_for_local_database¶
- class get_remote_project_for_local_database[source]¶
Bases:
Get the Remote Project for a Database
- Parameters:
database – BN database, potentially with collaboration metadata
- Returns:
Remote project from one of the connected remotes, or None if not found or if projects are not pulled
- Raises:
RuntimeError – If there was an error
get_remote_snapshot_for_local¶
- class get_remote_snapshot_for_local[source]¶
Bases:
Get the remote snapshot associated with a local snapshot (if it exists)
- Parameters:
snap – Local snapshot
- Returns:
Remote snapshot if it exists, or None if not
- Raises:
RuntimeError – If there was an error
ignore_snapshot¶
- class ignore_snapshot[source]¶
Bases:
Ignore a snapshot from database syncing operations
- Parameters:
database – Parent database
snapshot – Snapshot to ignore
- Raises:
RuntimeError – If there was an error
is_collaboration_database¶
is_snapshot_ignored¶
- class is_snapshot_ignored[source]¶
Bases:
Test if a snapshot is ignored from the database
- Parameters:
database – Parent database
snapshot – Snapshot to test
- Returns:
True if snapshot should be ignored
- Raises:
RuntimeError – If there was an error
merge_database¶
- class merge_database[source]¶
Bases:
Merge all leaf snapshots in a database down to a single leaf snapshot.
- Parameters:
database – Database to merge
conflict_handler – Function to call for progress updates
progress – Function to call to resolve snapshot conflicts
- Raises:
RuntimeError – If there was an error (or the operation was cancelled)
pull_database¶
- class pull_database[source]¶
Bases:
Pull updated snapshots from the remote. Merge local changes with remote changes and potentially create a new snapshot for unsaved changes, named via name_changeset.
- Parameters:
database – Database to pull
file – Remote File to pull to
conflict_handler – Function to call to resolve snapshot conflicts
progress – Function to call for progress updates
name_changeset – Function to call for naming a pushed changeset, if necessary
- Raises:
RuntimeError – If there was an error (or the operation was cancelled)
push_database¶
- class push_database[source]¶
Bases:
Push locally added snapshots to the remote
- Parameters:
database – Database to push
file – Remote File to push to
progress – Function to call for progress updates
- Raises:
RuntimeError – If there was an error (or the operation was cancelled)
sync_database¶
- class sync_database[source]¶
Bases:
Completely sync a database, pushing/pulling/merging/applying changes
- Parameters:
database – Database to sync
file – File to sync with
conflict_handler – Function to call to resolve snapshot conflicts
progress – Function to call for progress updates
name_changeset – Function to call for naming a pushed changeset, if necessary
- Raises:
RuntimeError – If there was an error (or the operation was cancelled)
upload_database¶
- class upload_database[source]¶
Bases:
Upload a file, with database, to the remote under the given project
- Parameters:
metadata – Local file with database
project – Remote project under which to place the new file
progress – Function to call for progress updates
name_changeset – Function to call for naming a pushed changeset, if necessary
parent_folder – Optional parent folder in which to place this file
- Returns:
Remote File created
- Raises:
RuntimeError – If there was an error