dropbox with a simple (dict-like or list-like) interface
Project description
dropboxdol
dropbox with a simple (dict-like or list-like) interface
To install: pip install dropboxdol
Setup
Note: To use dropboxdol, you'll need to have a dropbox access token.
Additionally, that token should be allowed to do the operation that you are doing.
For example, you only need the "sharing.write" permission to CREATE a (new) shared link.
See more information in Dropbox's Auth Guide. Essentially, you need to make an "app" here and get a token for it. No worries, it's quick and easy (just give the "app" a name) and give it a scope and permissions, then generate your token (and put it somewhere safe).
By default, dropboxdol looks for the access token in the DROPBOX_ACCESS_TOKEN environment variable. You can put your token there for easy interactions, but you can also specify another environment variable, or the access token itself, in the access_token argument of the functions and classes that need it. First, dropboxdol will look for the access_token string you gave it in the environment variables, and if it doesn't find it, it will assume you gave it the access token itself.
Examples
Get dropbox links for local files/folders
(Your token needs the "sharing.write" permission to CREATE a (new) shared link.)
>>> from dropboxdol import dropbox_link
>>> local_file = '/Users/thorwhalen/Dropbox/Apps/py2store/py2store_data/test.txt'
>>> dropbox_url = dropbox_link(local_file)
>>> print(dropbox_url)
https://www.dropbox.com/scl/fi/3o8ooqje4f497npxdeiwg/test.txt?rlkey=x9jsd8u7k147x6fzc7stxozqe&dl=0
If you want to talk "relative" to the dropbox root dir, do this:
>>> from functools import partial
>>> my_dropbox_link = partial(dropbox_link, dropbox_local_rootdir='/Users/thorwhalen/Dropbox')
If you want a "direct (download) link", do this:
>>> dl1_link = my_dropbox_link('Apps/py2store/py2store_data/test.txt', dl=1)
'https://www.dropbox.com/scl/fi/3o8ooqje4f497npxdeiwg/test.txt?rlkey=x9jsd8u7k147x6fzc7stxozqe&dl=1'
Easy read/write access to your dropbox files
A persister for dropbox.
>>> import json
>>> import os
>>> from dropboxdol import DropboxPersister
>>> configs = json.load(open(os.path.expanduser('~/.py2store_configs.json')))
>>> s = DropboxPersister('/py2store_data/test/', **configs['dropbox']['__init__kwargs'])
>>> if '/py2store_data/test/_can_remove' in s:
... del s['/py2store_data/test/_can_remove']
...
>>>
>>> n = len(s)
>>> if n == 1:
... assert list(s) == ['/py2store_data/test/_can_remove']
...
>>> s['/py2store_data/test/_can_remove'] = b'this is a test'
>>> assert len(s) == n + 1
>>> assert s['/py2store_data/test/_can_remove'] == b'this is a test'
>>> '/py2store_data/test/_can_remove' in s
True
>>> del s['/py2store_data/test/_can_remove']
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dropboxdol-0.0.4.tar.gz.
File metadata
- Download URL: dropboxdol-0.0.4.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad36ce46f90354e13ee5d212e7eb8e3b792f647dbd81b4ea4c44ed3dca791409
|
|
| MD5 |
08f0c7e7bf93b03807d58ae867b3cce7
|
|
| BLAKE2b-256 |
b7f8c5cdfceef873a444ea3cdaded2b7fe97149d297025c7f6a1a87ad37191dc
|
File details
Details for the file dropboxdol-0.0.4-py3-none-any.whl.
File metadata
- Download URL: dropboxdol-0.0.4-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4920de0cb6a11e0c98f425001477fefee616f9980343b57bbda9b6f982b596a
|
|
| MD5 |
56fe2c84b7195f669eb3a0731747bfde
|
|
| BLAKE2b-256 |
2b6f246ef0535c37bdc38f8114cd22fe710f9eb4ddda387f60a87eb7c811c8b3
|