Skip to content

Commit a77ab66

Browse files
committed
Fixes for Andrea.
1 parent b0b3e7b commit a77ab66

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

docs/api.md

+26-6
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,10 @@ information.
345345
#### `pyscript.fs.mount`
346346

347347
Mount a directory on the user's local filesystem into the browser's virtual
348-
filesystem. If no previous transient user activation has taken place, this
349-
function will result in a minimalist dialog to provide the
350-
[transient user activation](https://developer.mozilla.org/en-US/docs/Glossary/Transient_activation).
348+
filesystem. If no previous
349+
[transient user activation](https://developer.mozilla.org/en-US/docs/Glossary/Transient_activation)
350+
has taken place, this function will result in a minimalist dialog to provide
351+
the required transient user activation.
351352

352353
This asynchronous function takes four arguments:
353354

@@ -356,7 +357,9 @@ This asynchronous function takes four arguments:
356357
* `mode` (default: `"readwrite"`) - indicates how the code may interact with
357358
the mounted filesystem. May also be just `"read"` for read-only access.
358359
* `id` (default: `"pyscript"`) - indicate a unique name for the handler
359-
associated with a directory on the user's local filesystem.
360+
associated with a directory on the user's local filesystem. This allows users
361+
to select different folders and mount them at the same path in the
362+
virtual filesystem.
360363
* `root` (default: `""`) - a hint to the browser for where to start picking the
361364
path that should be mounted in Python. Valid values are: `desktop`,
362365
`documents`, `downloads`, `music`, `pictures` or `videos` as per
@@ -370,6 +373,23 @@ from pyscript import fs
370373
await fs.mount("/local")
371374
```
372375

376+
If the call to `fs.mount` happens after a click or other transient event, the
377+
confirmation dialog will not be shown.
378+
379+
```python title="Mounting without a transient event dialog."
380+
from pyscript import fs
381+
382+
383+
async def handler(event):
384+
"""
385+
The click event that calls this handler is already a transient event.
386+
"""
387+
await fs.mount("/local")
388+
389+
390+
my_button.onclick = handler
391+
```
392+
373393
#### `pyscript.fs.sync`
374394

375395
Given a named `path` for a mount point on the browser's virtual filesystem,
@@ -384,8 +404,8 @@ await fs.sync("/local")
384404
#### `pyscript.fs.unmount`
385405

386406
Asynchronously unmount the named `path` from the browser's virtual filesystem.
387-
This will free up memory. A call to [`fs.sync`](#pyscriptfssync) is
388-
automatically made before unmounting.
407+
This will free up memory and allow you to re-use the path to mount a different
408+
directory.
389409

390410
```python title="Unmount from the virtual filesystem."
391411
await fs.unmount("/local")

docs/user-guide/filesystem.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
As you know, the filesystem is where you store files. For Python to work there
44
needs to be a filesystem in which Python packages, modules and data for your
55
apps can be found. When you `import` a library, or when you `open` a file, it
6-
is on the filesystem that Python looks.
6+
is on the in-browser virtual filesystem that Python looks.
77

88
However, things are not as they may seem.
99

@@ -31,7 +31,7 @@ PyScript interacts with two filesystems.
3131
Access to the device's local filesystem **is only available in Chromium
3232
based browsers**.
3333

34-
Firefox and Safari do not support this capability, and so it is not
34+
Firefox and Safari do not support this capability (yet), and so it is not
3535
available to PyScript running in these browsers.
3636

3737
## The in-browser filesystem

0 commit comments

Comments
 (0)