Skip to content

Commit

Permalink
Adding widget RemoteFileSelector
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrotsmnrd committed Feb 4, 2024
1 parent a0c5d40 commit 2f53a6b
Show file tree
Hide file tree
Showing 5 changed files with 443 additions and 0 deletions.
39 changes: 39 additions & 0 deletions examples/reference/widgets/RemoteFileSelector.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import panel as pn\n",
"pn.extension()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The ``RemoteFileSelector`` widget allows browsing a distant filesystem and selecting one or more files in a directory.\n",
"\n",
"A ``RemoteFileSelector`` always relies on a ``RemoteFileProvider``, that is responsible for fetching data from the distant filesystem, handling the connection. The ``RemoteFileSelector`` is responsible for showing the distant filesystem and allow for a selection of files. Its behavior is similar to ``FileSelector``\n",
"\n",
"\n",
"#### Parameters:\n",
"\n",
"// TODO\n",
"\n",
"\n",
"___"
]
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
20 changes: 20 additions & 0 deletions panel/tests/widgets/test_remote_file_selector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# to fake delays in DummyRemoteFileProvider
import time

from pathlib import PurePosixPath

from panel.widgets import RemoteFileProvider


class DummyRemoteFileProvider(RemoteFileProvider):

def __init__(self):
super().__init__()

async def ls(self, path:PurePosixPath):
time.sleep(1)
if str(path) == '/':
return [f'dir_{l}' for l in 'ABCDEF' ], [f'file_{n}' for n in '123456' ]
else:
last_letter = path.parts[-1].replace("dir_", "")
return [f'dir_{last_letter}{l}' for l in 'ABCDEF' ], [f'file_{last_letter + n}' for n in '123456' ]
4 changes: 4 additions & 0 deletions panel/widgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
)
from .misc import FileDownload, JSONEditor, VideoStream # noqa
from .player import DiscretePlayer, Player # noqa
from .remote_file_selector import ( # noqa
RemoteFileProvider, RemoteFileSelector, S3RemoteFileProvider,
)
from .select import ( # noqa
AutocompleteInput, CheckBoxGroup, CheckButtonGroup, ColorMap,
CrossSelector, MultiChoice, MultiSelect, NestedSelect, RadioBoxGroup,
Expand Down Expand Up @@ -127,6 +130,7 @@
"RadioBoxGroup",
"RadioButtonGroup",
"RangeSlider",
"RemoteFileSelector",
"Select",
"SpeechToText",
"Spinner",
Expand Down
Loading

0 comments on commit 2f53a6b

Please sign in to comment.