> built 2026-12-01 15:51 UTC from 6b6bdbc (master) · dropboxdol 0.0.17. Details: build_info.json

# index.html.md

<!-- generated by epythet -->

# dropboxdol

dropbox with a simple (dict-like or list-like) interface

To install:	`pip install dropboxdol`

# A public shared folder, no token

A folder shared as “anyone with the link” can be read without any app key or token:

```python
from dropboxdol import DropboxSharedFolderZip, shared_folder_name

url = "https://www.dropbox.com/scl/fo/..."
shared_folder_name(url)                      # the folder's name (headers only)
s = DropboxSharedFolderZip(url, include=lambda p: p.endswith(".mp3"))
list(s)                                      # paths inside the folder
s["sub/song.mp3"]                            # bytes
```

It downloads the folder’s zip once (pass `cache_dir=` to keep it between runs,
`max_bytes=` to cap it), so for a large folder the token-based readers below are cheaper.

# 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](https://developers.dropbox.com/oauth-guide).

By default, `dropboxdol` looks for the access tokens and other information is
(well, really, the dropbox API) needs)
in the `"default_dropbox_config.json"` file of the dropboxdol app data.
You can interact with those files via `dropboxdol.config_store`, which has a dict-like interface to the files in that folder.

If you don’t have a `"default_dropbox_config.json"` file, you’ll need to specify the
connection config explicitly (by specifying a config dict, a filepath, filename of the
`config_store`).

Note that at this point, dropbox only dishes out temporary access tokens.
This means you can’t just save an access token once and be over with it.
So to get the convenience of automatic connections, you’ll need to specify not only a
`oauth2_access_token`, but also a `oauth2_refresh_token`, an `app_key` and an `app_secret`.

You can read all about that annoying stuff in the [Dropbox’s Auth Guide](https://developers.dropbox.com/oauth-guide).

But here’s a few things to make it a bit less painful:

* make an “app” in the [app console](https://www.dropbox.com/developers/apps?_tk=pilot_lp&_ad=topbar4&_camp=myapps)
* specify scope and permissions you want on it
* note down the app key and the app secret

then use the following, which will walk you through the steps to get your access and refresh tokens.

These will then be stored in the `config_file` of your choice, so that all you have to
do is mention the file to get the connection.

```python
from dropboxdol import create_config_file

create_config_file(
    config_file="NAME_OF_YOUR_APP_OR_WHATEVER_NAME_YOU_WILL_REMEMBER.json",
    app_key="YOUR_APP_KEY",
    app_secret="YOUR_APP_SECRET",
)
```

If you already have a config file for this app, with app_key and app_secret,
you can update the tokens by doing this:

```python
from dropboxdol import complete_config_file_with_refresh_token

complete_config_file_with_refresh_token(
    config_file="NAME_OF_YOUR_APP_OR_WHATEVER_YOU_CALLED_THAT_CONFIG.json",
)
```

If you want to edit some configs, you can do so by editing the file directly, or use
`create_or_edit_config_file`.

```python
from dropboxdol import create_or_edit_config_file

create_or_edit_config_file(
    config_file="CONFIG_FILE.json",
    # whatever edits you want to make... (specifying None will skip that config, leaving it unchanged)
    oauth2_access_token=None,
    oauth2_refresh_token=None,
    app_key=None,
    app_secret=None,
)
```

# Examples

## Get a dropbox “store”

### From a link

```python
from dropboxdol import DropboxLinkReaderWithToken

s = DropboxLinkReaderWithToken(
    url="https://www.dropbox.com/sh/0ru09jmk0w9tdnr/AAA-PPON2sYmwUUoGQpBQh1Ia?dl=0"
)
keys = list(s)
keys
```

```none
['inner_folder',
'b1467f55540c4695bf483bc542e43256',
'0b98e2af76c94a0a9cc2808866dd62de',
'3372aa35ea444c758bfa2e4599b2576d',
'9de9d98a4c4648cca1bc1131c307a365',
'91c744890d374dd8bc914f1153311b0c',
'57af886dd22f4a23a678a3de3eb996a0',
'43ba127e5e9245ec983c9f39e4ed7306']
```

### From a local path (but talking to the remote files)

```python
from dropboxdol import DropboxFiles
from i2 import Sig

t = DropboxFiles("/Apps/py2store/py2store_data")
list(t)
```

```none
['/test', '/test.txt', '/another_test.txt']
```

```python
t["/test.txt"]
```

```none
b'This is a test.\nSee it work.\nAnd what about unicode? \xc3\xa8\xc3\xa9\xc3\xaa\xc3\xab\xc4\x93\xc4\x97\xc4\x99?'
```

## Get dropbox links for local files/folders

(Your token needs the “sharing.write” permission to CREATE a (new) shared link.)

```python
>>> 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)
```

```none
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:

```python
>>> 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:

```python
>>> dl1_link = my_dropbox_link('Apps/py2store/py2store_data/test.txt', dl=1)
```

```none
'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.

```python
>>> 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']
```

<p class="epythet-aggregates">This documentation as a single file: <a href="dropboxdol.md">dropboxdol.md</a> (Markdown, for agents).</p>


# _autosummary/dropboxdol.base.html.md

# dropboxdol.base

Base functions for dropboxdol.

### Functions

| [`create_or_get_shared_link`](_autosummary/dropboxdol.base.html.md#dropboxdol.base.create_or_get_shared_link)(dbx, dbx_file_path)   | Create a shared link for the given Dropbox file path.                 |
|--------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------|
| [`dropbox_link`](_autosummary/dropboxdol.base.html.md#dropboxdol.base.dropbox_link)(path, \*[, ...])                   | Returns a shareable Dropbox URL for the file at the given local path. |

### Classes

| [`DropboxBinaryStore`](_autosummary/dropboxdol.base.html.md#dropboxdol.base.DropboxBinaryStore)                              |                          |
|--------------------------------------------------------------------------------------------------|--------------------------|
| [`DropboxFiles`](_autosummary/dropboxdol.base.html.md#dropboxdol.base.DropboxFiles)([rootdir, connection_config, ...]) |                          |
| [`DropboxLinkReaderWithToken`](_autosummary/dropboxdol.base.html.md#dropboxdol.base.DropboxLinkReaderWithToken)(url[, ...])          |                          |
| [`DropboxPersister`](_autosummary/dropboxdol.base.html.md#dropboxdol.base.DropboxPersister)([rootdir, ...])                | A persister for dropbox. |
| [`DropboxTextFiles`](_autosummary/dropboxdol.base.html.md#dropboxdol.base.DropboxTextFiles)([rootdir, ...])                |                          |
| [`DropboxTextStore`](_autosummary/dropboxdol.base.html.md#dropboxdol.base.DropboxTextStore)                                |                          |

### dropboxdol.base.DropboxBinaryStore

alias of [`DropboxFiles`](_autosummary/dropboxdol.base.html.md#dropboxdol.base.DropboxFiles)

### *class* dropboxdol.base.DropboxFiles(rootdir='', , connection_config='default_dropbox_config.json', files_upload_kwargs=None, files_list_folder_kwargs=None, rev=None)

Bases: `PrefixRelativizationMixin`, `Store`, [`DropboxPersister`](_autosummary/dropboxdol.base.html.md#dropboxdol.base.DropboxPersister)

### *class* dropboxdol.base.DropboxLinkReaderWithToken(url, connection_config='default_dropbox_config.json', , path='', recursive=False, include_media_info=False, include_deleted=False, include_has_explicit_shared_members=False, include_mounted_folders=True, limit=None, include_property_groups=None, include_non_downloadable_files=True)

Bases: `ReadOnlyMixin`, [`DropboxPersister`](_autosummary/dropboxdol.base.html.md#dropboxdol.base.DropboxPersister)

### *class* dropboxdol.base.DropboxPersister(rootdir='', , connection_config='default_dropbox_config.json', files_upload_kwargs=None, files_list_folder_kwargs=None, rev=None)

Bases: `KvPersister`

A persister for dropbox.
You need to have the python connector (if you don’t: pip install dropbox)
You also need to have a token for your dropbox app. If you don’t it’s a google away.
Finally, for the test below, you need to put this token in ~/.py2store_configs.json’ under key
dropbox._\_init_\_kwargs, and have a folder named /py2store_data/test/ in your app space.

```pycon
>>> from dropboxdol.tests.test_dropbox import test_config
>>> from dropboxdol import DropboxPersister
>>> s = DropboxPersister('/py2store_data/test/', connection_config=test_config)
>>> 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']
```

### *class* dropboxdol.base.DropboxTextFiles(rootdir='', , connection_config='default_dropbox_config.json', files_upload_kwargs=None, files_list_folder_kwargs=None, rev=None)

Bases: [`DropboxFiles`](_autosummary/dropboxdol.base.html.md#dropboxdol.base.DropboxFiles)

### dropboxdol.base.DropboxTextStore

alias of [`DropboxTextFiles`](_autosummary/dropboxdol.base.html.md#dropboxdol.base.DropboxTextFiles)

### dropboxdol.base.create_or_get_shared_link(dbx, dbx_file_path)

Create a shared link for the given Dropbox file path.

If a shared link already exists, list and return the first one.
Raises an exception with detailed information on authentication errors.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### dropboxdol.base.dropbox_link(path, , dropbox_local_rootdir=None, dl=0, access_config='default_dropbox_config.json')

Returns a shareable Dropbox URL for the file at the given local path.

The function:

> 1. Retrieves the access token from os.environ using the given key or uses the provided token.
> 2. Determines the absolute local file path (using dropbox_path if needed).
> 3. Computes the Dropbox file path relative to the Dropbox folder.
> 4. Attempts to create a shared link, or retrieves an existing one if it already exists.
> 5. Modifies the URL to include the specified ‘dl’ parameter (e.g., dl=1 for direct download).
* **Parameters:**
  * **path** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – The file path (absolute or relative).
  * **dropbox_local_rootdir** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – The local root Dropbox folder. If not provided, it will be inferred.
  * **dl** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – The value for the ‘dl’ parameter in the shared URL (default is 0).
  * **access_config** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)) – The access configuration (dict or file path)
* **Returns:**
  The modified shared URL.
* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)
* **Raises:**
  * [**FileNotFoundError**](https://docs.python.org/3/builtins/exceptions.html#FileNotFoundError) – If the file does not exist.
  * [**Exception**](https://docs.python.org/3/builtins/exceptions.html#Exception) – For issues with path computation or Dropbox API errors.


# _autosummary/dropboxdol.connection.html.md

# dropboxdol.connection

Objects to connect to Dropbox.

### Functions

| `complete_config_file_with_refresh_token`(...)                                                     |                                                                                |
|----------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|
| `config_file_to_dict`(config_filepath)                                                             |                                                                                |
| [`copy_config_file`](_autosummary/dropboxdol.connection.html.md#dropboxdol.connection.copy_config_file)(src_config_file[, ...])          | Copy a configuration file from one location to another.                        |
| [`create_config_file`](_autosummary/dropboxdol.connection.html.md#dropboxdol.connection.create_config_file)(config_file, \*, app_key, ...) | Create a configuration file for a Dropbox client.                              |
| `create_or_edit_config_file`(config_file, \*[, ...])                                               |                                                                                |
| [`get_client`](_autosummary/dropboxdol.connection.html.md#dropboxdol.connection.get_client)([config])                              | Return a Dropbox client using the best available configuration source.         |
| [`get_client_from_args`](_autosummary/dropboxdol.connection.html.md#dropboxdol.connection.get_client_from_args)(oauth2_access_token[, ...])  | Create a Dropbox client using explicit credentials with additional validation. |
| [`get_client_from_config_file`](_autosummary/dropboxdol.connection.html.md#dropboxdol.connection.get_client_from_config_file)(config_filepath)      | Create a Dropbox client by loading configuration from a JSON file.             |
| [`get_client_from_environment_vars`](_autosummary/dropboxdol.connection.html.md#dropboxdol.connection.get_client_from_environment_vars)(...[, ...])      | Create a Dropbox client using configuration from environment variables.        |
| [`get_envvar_if_upper_case_and_exists`](_autosummary/dropboxdol.connection.html.md#dropboxdol.connection.get_envvar_if_upper_case_and_exists)(config)       | Retrieve a configuration value.                                                |
| [`get_tokens_interactive`](_autosummary/dropboxdol.connection.html.md#dropboxdol.connection.get_tokens_interactive)(app_key, app_secret)       | Runs an interactive OAuth flow to obtain an access token and a refresh token.  |

### dropboxdol.connection.copy_config_file(src_config_file, dest_config_file=None)

Copy a configuration file from one location to another.

If the destination file already exists, a FileExistsError will be raised.

### dropboxdol.connection.create_config_file(config_file, , app_key, app_secret, oauth2_access_token=None, oauth2_refresh_token=None)

Create a configuration file for a Dropbox client.

If the file already exists, a FileExistsError will be raised.
The `config_file` must be a sring ending with ‘.json’.
If oauth2_refresh_token is not given, an interactive flow will be used to obtain it,
also replacing the oauth2_access_token.

### dropboxdol.connection.get_client(config='default_dropbox_config.json', \*\*kwargs)

Return a Dropbox client using the best available configuration source.

Priority:

> 1. If an oauth2_access_token is provided and ends with ‘.json’, load configuration from that file.
> 2. Else, if the environment variable (named by oauth2_access_token) exists, use environment variables.
> 3. Otherwise, use explicit parameters provided via kwargs.

Expected keyword arguments:

> - oauth2_access_token
> - oauth2_refresh_token
> - app_key
> - app_secret
* **Return type:**
  `Dropbox`

### dropboxdol.connection.get_client_from_args(oauth2_access_token, oauth2_refresh_token=None, app_key=None, app_secret=None)

Create a Dropbox client using explicit credentials with additional validation.

Validation includes:

> - Ensuring that oauth2_access_token is provided and is a non-empty string.
> - If any of oauth2_refresh_token, app_key, or app_secret are provided, then all must be provided
>   to enable auto-refresh.
> - Issuing soft warnings if any of the parameters appear to be environment variable names
>   (all uppercase), which might indicate that the caller intended to pass literal values.
* **Parameters:**
  * **oauth2_access_token** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – The Dropbox access token.
  * **oauth2_refresh_token** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – The Dropbox refresh token.
  * **app_key** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Your Dropbox app key.
  * **app_secret** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Your Dropbox app secret.
* **Returns:**
  A Dropbox client instance.
* **Return type:**
  `Dropbox`

### dropboxdol.connection.get_client_from_config_file(config_filepath)

Create a Dropbox client by loading configuration from a JSON file.

The JSON file must contain the keys:

> - “oauth2_access_token”
> - “oauth2_refresh_token”
> - “app_key”
> - “app_secret”
* **Raises:**
  * [**FileNotFoundError**](https://docs.python.org/3/builtins/exceptions.html#FileNotFoundError) – If the config file does not exist.
  * [**Exception**](https://docs.python.org/3/builtins/exceptions.html#Exception) – If required keys are missing.
* **Return type:**
  `Dropbox`

### dropboxdol.connection.get_client_from_environment_vars(oauth2_access_token, oauth2_refresh_token=None, app_key=None, app_secret=None)

Create a Dropbox client using configuration from environment variables.

The provided parameter names are interpreted as the names of the environment variables.
For example, calling:

> get_client_from_environment_vars(“DROPBOX_ACCESS_TOKEN”, “DROPBOX_REFRESH_TOKEN”,
> : “DROPBOX_APP_KEY”, “DROPBOX_APP_SECRET”)

will use the values from os.environ (if they exist), or fall back to the literal strings.

* **Return type:**
  `Dropbox`

### dropboxdol.connection.get_envvar_if_upper_case_and_exists(config)

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:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### dropboxdol.connection.get_tokens_interactive(app_key, app_secret)

Runs an interactive OAuth flow to obtain an access token and a refresh token.

Ensure you pass your Dropbox app key and secret. This flow will print an
authorization URL. Visit the URL in your browser, authorize the app, then
paste the resulting code into the prompt.

* **Returns:**
  A tuple (access_token, refresh_token)


# _autosummary/dropboxdol.html.md

# dropboxdol

Access dropbox with dict-like interface.

### Modules

| [`base`](_autosummary/dropboxdol.base.html.md#module-dropboxdol.base)                   | Base functions for dropboxdol.                                                       |
|------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|
| [`connection`](_autosummary/dropboxdol.connection.html.md#module-dropboxdol.connection)       | Objects to connect to Dropbox.                                                       |
| [`shared_folder`](_autosummary/dropboxdol.shared_folder.html.md#module-dropboxdol.shared_folder) | Read a public Dropbox shared-folder link with no token, through its folder download. |
| [`util`](_autosummary/dropboxdol.util.html.md#module-dropboxdol.util)                   | Utility functions for DropboxDOL.                                                    |


# _autosummary/dropboxdol.shared_folder.html.md

# dropboxdol.shared_folder

Read a public Dropbox shared-folder link with no token, through its folder download.

A shared-folder link (`https://www.dropbox.com/scl/fo/...`) with `dl=1` downloads the
whole folder as one zip, and its `Content-Disposition` names the folder. That needs no
app key or access token, unlike `dropboxdol.DropboxLinkReaderWithToken`; the
cost is a whole-folder download per refresh, so for a large folder the token-based
reader stays the better choice (i2mint/dropboxdol#8).

```pycon
>>> download_url("https://www.dropbox.com/scl/fo/abc/xyz?rlkey=k&dl=0")
'https://www.dropbox.com/scl/fo/abc/xyz?rlkey=k&dl=1'
```

`DropboxSharedFolderZip(url)` is a `Mapping[str, bytes]` of the files in the folder,
keyed by their path inside it; `shared_folder_name(url)` is the folder’s name.
Every request goes through one `http(url)` callable (default: `urllib`, following
redirects only to Dropbox’s own https hosts), so tests and other clients plug in there.

### Module Attributes

| [`DROPBOX_HOSTS`](_autosummary/dropboxdol.shared_folder.html.md#dropboxdol.shared_folder.DROPBOX_HOSTS)        | Hosts a shared-folder link may name.                                                      |
|-----------------------------------------------------------------------|-------------------------------------------------------------------------------------------|
| [`DROPBOX_FOLDER_PATHS`](_autosummary/dropboxdol.shared_folder.html.md#dropboxdol.shared_folder.DROPBOX_FOLDER_PATHS) | Path prefixes of shared-folder links (`scl/fo` today, `sh` for older links).              |
| [`DOWNLOAD_DOMAINS`](_autosummary/dropboxdol.shared_folder.html.md#dropboxdol.shared_folder.DOWNLOAD_DOMAINS)     | Domains a download may be redirected to (the host itself or a subdomain of it).           |
| [`DFLT_MAX_BYTES`](_autosummary/dropboxdol.shared_folder.html.md#dropboxdol.shared_folder.DFLT_MAX_BYTES)       | Default ceiling for the download and for the files it holds, uncompressed.                |
| [`DFLT_MAX_MEMBERS`](_autosummary/dropboxdol.shared_folder.html.md#dropboxdol.shared_folder.DFLT_MAX_MEMBERS)     | Default ceiling for the number of entries in the zip (each costs memory before any read). |

### Functions

| [`download_url`](_autosummary/dropboxdol.shared_folder.html.md#dropboxdol.shared_folder.download_url)(url)                   | The shared-folder link with `dl=1` (its zip download).                                                                       |
|--------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [`shared_folder_name`](_autosummary/dropboxdol.shared_folder.html.md#dropboxdol.shared_folder.shared_folder_name)(url, \*[, http]) | The shared folder's name: its download's file name without `.zip`.                                                           |
| [`urlopen_dropbox`](_autosummary/dropboxdol.shared_folder.html.md#dropboxdol.shared_folder.urlopen_dropbox)(url, \*[, timeout]) | GET `url` (a response: a context manager with `.headers` and `.read(n)`), following redirects only to Dropbox's https hosts. |

### Classes

| [`DropboxSharedFolderZip`](_autosummary/dropboxdol.shared_folder.html.md#dropboxdol.shared_folder.DropboxSharedFolderZip)(url, \*[, include, ...])   | The files of a public Dropbox shared folder, `{path inside the folder: bytes}`, read from the folder's zip download, with no token.   |
|----------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|

### Exceptions

| [`SharedFolderError`](_autosummary/dropboxdol.shared_folder.html.md#dropboxdol.shared_folder.SharedFolderError)   | A shared-folder link that cannot be read (not a folder link, not shared, too big).   |
|----------------------------------------------------------------------|--------------------------------------------------------------------------------------|

### dropboxdol.shared_folder.DFLT_MAX_BYTES *= 4294967296*

Default ceiling for the download and for the files it holds, uncompressed.

### dropboxdol.shared_folder.DFLT_MAX_MEMBERS *= 100000*

Default ceiling for the number of entries in the zip (each costs memory before any read).

### dropboxdol.shared_folder.DOWNLOAD_DOMAINS *= ('dropbox.com', 'dropboxusercontent.com')*

Domains a download may be redirected to (the host itself or a subdomain of it).

### dropboxdol.shared_folder.DROPBOX_FOLDER_PATHS *= ('/scl/fo/', '/sh/')*

Path prefixes of shared-folder links (`scl/fo` today, `sh` for older links).

### dropboxdol.shared_folder.DROPBOX_HOSTS *= ('dropbox.com', 'www.dropbox.com')*

Hosts a shared-folder link may name.

### *class* dropboxdol.shared_folder.DropboxSharedFolderZip(url, \*, include=None, cache_dir=None, max_bytes=4294967296, max_members=100000, http=<function urlopen_dropbox>)

Bases: [`Mapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping)

The files of a public Dropbox shared folder, `{path inside the folder: bytes}`,
read from the folder’s zip download, with no token.

The zip is downloaded once, on first use: into `cache_dir` (then reused by later
instances, until [`refresh()`](_autosummary/dropboxdol.shared_folder.html.md#dropboxdol.shared_folder.DropboxSharedFolderZip.refresh)), or into an anonymous temporary file that goes
away with the object. Folder entries and paths that would leave the folder are not
keys. The download, and the files it holds once uncompressed, may not exceed
`max_bytes` ([`SharedFolderError`](_autosummary/dropboxdol.shared_folder.html.md#dropboxdol.shared_folder.SharedFolderError) otherwise).

* **Parameters:**
  * **url** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – The shared-folder link (`https://www.dropbox.com/scl/fo/...`).
  * **include** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Callable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)[[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)], [`bool`](https://docs.python.org/3/builtins/functions.html#bool)]]) – `include(path) -> bool`: which files are keys (default: all),
    e.g. `lambda p: p.endswith(".mp3")`. It may not read this store. Excluded files do not count toward
    `max_bytes` once the zip is here.
  * **cache_dir** – A folder to keep the zip in, named from the link’s hash.
  * **max_bytes** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Ceiling for the download and for the included files’ total size.
  * **max_members** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Ceiling for the number of entries in the zip.
  * **http** ([`Callable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable)) – `http(url)` returning a response (a context manager with
    `.headers` and `.read(n)`). Default [`urlopen_dropbox()`](_autosummary/dropboxdol.shared_folder.html.md#dropboxdol.shared_folder.urlopen_dropbox).

Use it as a context manager (or call [`close()`](_autosummary/dropboxdol.shared_folder.html.md#dropboxdol.shared_folder.DropboxSharedFolderZip.close)) to release the open zip.
Reads are thread-safe; iterating while another thread calls [`refresh()`](_autosummary/dropboxdol.shared_folder.html.md#dropboxdol.shared_folder.DropboxSharedFolderZip.refresh) is not
(the keys may come from one download and the values from the next).

#### *property* cache_path *: [Optional](https://docs.python.org/3/library/typing.html#typing.Optional)[[Path](https://docs.python.org/3/library/pathlib.html#pathlib.Path)]*

Where the zip is kept, when `cache_dir` is given.

#### close()

Release the open zip (it is reopened, from the cache or a new download, on
next use).

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

#### refresh()

Download the folder again (the cached zip is replaced).

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### *exception* dropboxdol.shared_folder.SharedFolderError

Bases: [`ValueError`](https://docs.python.org/3/builtins/exceptions.html#ValueError)

A shared-folder link that cannot be read (not a folder link, not shared, too big).

### dropboxdol.shared_folder.download_url(url)

The shared-folder link with `dl=1` (its zip download). Refuses anything but an
https Dropbox shared-folder link, so a caller cannot be made to fetch another host.

```pycon
>>> download_url("https://dropbox.com/sh/abc/def?dl=0&raw=1")
'https://dropbox.com/sh/abc/def?dl=1'
>>> download_url("https://example.com/scl/fo/abc")
Traceback (most recent call last):
...
dropboxdol.shared_folder.SharedFolderError: not a Dropbox shared-folder link (https://www.dropbox.com/scl/fo/...): 'https://example.com/scl/fo/abc'
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### dropboxdol.shared_folder.shared_folder_name(url, \*, http=<function urlopen_dropbox>)

The shared folder’s name: its download’s file name without `.zip`. Only the
response headers are read, not the body. `""` when Dropbox names none. The name
comes from the server: it is reduced to a plain name (no folder part), but treat
it as untrusted text.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### dropboxdol.shared_folder.urlopen_dropbox(url, , timeout=60)

GET `url` (a response: a context manager with `.headers` and `.read(n)`),
following redirects only to Dropbox’s https hosts. The default `http` here.


# _autosummary/dropboxdol.util.html.md

# dropboxdol.util

Utility functions for DropboxDOL.

### Functions

| [`compute_dbx_file_path`](_autosummary/dropboxdol.util.html.md#dropboxdol.util.compute_dbx_file_path)(local_full_path, ...)   | Compute the Dropbox file path from the local file path and the local Dropbox folder.   |
|------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------|
| [`get_config_val`](_autosummary/dropboxdol.util.html.md#dropboxdol.util.get_config_val)(config_key)                    | Retrieve a configuration value.                                                        |
| [`get_local_full_path`](_autosummary/dropboxdol.util.html.md#dropboxdol.util.get_local_full_path)(path[, ...])              | Determine the absolute local file path and the local Dropbox folder.                   |
| [`modify_url_dl`](_autosummary/dropboxdol.util.html.md#dropboxdol.util.modify_url_dl)(shared_url, dl)                 | Adjust the Dropbox shared URL to include the desired 'dl' parameter.                   |

### dropboxdol.util.compute_dbx_file_path(local_full_path, dropbox_local_rootdir)

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.

```pycon
>>> 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:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### dropboxdol.util.get_config_val(config_key)

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:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### dropboxdol.util.get_local_full_path(path, dropbox_local_rootdir=None)

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.
* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]
* **Returns:**
  A tuple (local_full_path, dropbox_local_rootdir)

### dropboxdol.util.modify_url_dl(shared_url, dl)

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.

```pycon
>>> 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:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)


# about-this-build.html.md

<!-- generated by epythet -->

# About this build

This documentation was built on **2026-12-01 15:51 UTC** from commit <a href="https://github.com/i2mint/dropboxdol/commit/6b6bdbced3d1d60e1e9c4bd81f9261d08d3538a7"><code>6b6bdbc</code></a> on branch <code>master</code>, for **dropboxdol 0.0.17** (from <code>pyproject.toml</code>).

#### WARNING
The documentation and the package may be misaligned:

- The documented version (0.0.17) is behind the latest release on PyPI (0.0.18): `pip install dropboxdol` gives newer code than these docs describe.

## Source

|                     |                                                                                                                                                          |
|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
| Commit              | <a href="https://github.com/i2mint/dropboxdol/commit/6b6bdbced3d1d60e1e9c4bd81f9261d08d3538a7"><code>6b6bdbced3d1d60e1e9c4bd81f9261d08d3538a7</code></a> |
| Branch              | <code>master</code>                                                                                                                                      |
| Tags at this commit | none                                                                                                                                                     |
| Working tree        | clean                                                                                                                                                    |
| Remote              | <code>https://github.com/i2mint/dropboxdol</code>                                                                                                        |

## Continuous integration

|              |                                                                                            |
|--------------|--------------------------------------------------------------------------------------------|
| Repository   | <code>i2mint/dropboxdol</code>                                                             |
| Run          | <a href="https://github.com/i2mint/dropboxdol/actions/runs/46683802285">46683802285</a>    |
| Ref          | <code>refs/heads/master</code>                                                             |
| Event commit | <code>6b6bdbced3d1d60e1e9c4bd81f9261d08d3538a7</code> (in the history of the built commit) |

## Tools

|          |         |
|----------|---------|
| epythet  | 0.2.25  |
| Sphinx   | 9.1.1   |
| docutils | 0.22.4  |
| Python   | 3.12.16 |

## Configuration as resolved

|               |                                                                  |
|---------------|------------------------------------------------------------------|
| theme         | <code>auto</code> (Sphinx theme <code>shibuya</code>)            |
| accent        | <code>#913149</code>                                             |
| api_generator | <code>autosummary</code>                                         |
| ignore        | <code>tests/</code>, <code>scrap/</code>, <code>examples/</code> |
| agent_outputs | <code>true</code>                                                |
| aggregates    | <code>md</code>                                                  |
| ai_artifacts  | <code>true</code>                                                |

## Package on PyPI

Latest release: <a href="https://pypi.org/project/dropboxdol/0.0.18/">0.0.18</a>, newer than the documented version (0.0.17).

## Reproduce

```bash
git clone https://github.com/i2mint/dropboxdol && cd dropboxdol
git checkout 6b6bdbced3d1d60e1e9c4bd81f9261d08d3538a7
pip install "epythet==0.2.25"
epythet quickstart . --ignore tests/ scrap/ examples/
```

The same data, for machines: <a href="build_info.json"><code>build_info.json</code></a> (schema version 1).


# api.html.md

# API reference

| [`dropboxdol`](_autosummary/dropboxdol.html.md#module-dropboxdol)   | Access dropbox with dict-like interface.   |
|---------------------------------------------------------------------------------|--------------------------------------------|


