dropboxdol.util#
Utility functions for DropboxDOL.
Functions
|
Compute the Dropbox file path from the local file path and the local Dropbox folder. |
|
Retrieve a configuration value. |
|
Determine the absolute local file path and the local Dropbox folder. |
|
Adjust the Dropbox shared URL to include the desired 'dl' parameter. |
- dropboxdol.util.compute_dbx_file_path(local_full_path, dropbox_local_rootdir)[source]#
Compute the Dropbox file path from the local file path and the local Dropbox folder.
The Dropbox file path is the relative path (with forward slashes) prefixed with a slash.
>>> compute_dbx_file_path("/path/to/Dropbox/file.txt", "/path/to/Dropbox") '/file.txt' >>> compute_dbx_file_path("/path/to/Dropbox/folder/file.txt", "/path/to/Dropbox") '/folder/file.txt'
- Return type:
- dropboxdol.util.get_config_val(config_key)[source]#
Retrieve a configuration value.
First checks os.environ for the given key. If present, returns its value; otherwise, returns the key itself (allowing you to pass literal values).
- Return type:
- dropboxdol.util.get_local_full_path(path, dropbox_local_rootdir=None)[source]#
Determine the absolute local file path and the local Dropbox folder.
If dropbox_local_rootdir is provided:
If path is relative, join it with dropbox_local_rootdir.
Otherwise, use path as is.
If dropbox_local_rootdir is not provided:
If path is absolute and contains “Dropbox”, infer the Dropbox folder.
Otherwise, raise a ValueError.
- dropboxdol.util.modify_url_dl(shared_url, dl)[source]#
Adjust the Dropbox shared URL to include the desired ‘dl’ parameter.
If the URL already has a ‘dl’ parameter, it is replaced; otherwise, the parameter is appended.
>>> modify_url_dl("https://www.dropbox.com/s/abc123/file.txt?dl=0", 1) 'https://www.dropbox.com/s/abc123/file.txt?dl=1' >>> modify_url_dl("https://www.dropbox.com/s/abc123/file.txt", 1) 'https://www.dropbox.com/s/abc123/file.txt?dl=1' >>> modify_url_dl("https://www.dropbox.com/s/abc123/file.txt?dl=0", 0) 'https://www.dropbox.com/s/abc123/file.txt?dl=0'
- Return type: