kopia lustrzana https://github.com/crahan/ipyfilechooser
One step closer
rodzic
fa44a64200
commit
34802201cb
|
@ -172,7 +172,8 @@ class FileChooser(VBox, ValueWidget):
|
||||||
show_hidden=self._show_hidden,
|
show_hidden=self._show_hidden,
|
||||||
prepend_icons=False,
|
prepend_icons=False,
|
||||||
show_only_dirs=self._show_only_dirs,
|
show_only_dirs=self._show_only_dirs,
|
||||||
filter_pattern=self._filter_pattern
|
filter_pattern=self._filter_pattern,
|
||||||
|
root_path=self._root_path
|
||||||
)
|
)
|
||||||
|
|
||||||
# file/folder display names
|
# file/folder display names
|
||||||
|
@ -181,7 +182,8 @@ class FileChooser(VBox, ValueWidget):
|
||||||
show_hidden=self._show_hidden,
|
show_hidden=self._show_hidden,
|
||||||
prepend_icons=self._use_dir_icons,
|
prepend_icons=self._use_dir_icons,
|
||||||
show_only_dirs=self._show_only_dirs,
|
show_only_dirs=self._show_only_dirs,
|
||||||
filter_pattern=self._filter_pattern
|
filter_pattern=self._filter_pattern,
|
||||||
|
root_path=self._root_path
|
||||||
)
|
)
|
||||||
|
|
||||||
# Dict to map real names to display names
|
# Dict to map real names to display names
|
||||||
|
|
|
@ -6,7 +6,7 @@ import sys
|
||||||
from typing import List, Sequence, Iterable, Optional
|
from typing import List, Sequence, Iterable, Optional
|
||||||
|
|
||||||
|
|
||||||
def get_subpaths(path: str, root_path: str) -> List[str]:
|
def get_subpaths(path: str, root_path: str = '') -> List[str]:
|
||||||
"""Walk a path and return a list of subpaths."""
|
"""Walk a path and return a list of subpaths."""
|
||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
path = os.path.dirname(path)
|
path = os.path.dirname(path)
|
||||||
|
@ -64,7 +64,8 @@ def get_dir_contents(
|
||||||
show_hidden: bool = False,
|
show_hidden: bool = False,
|
||||||
prepend_icons: bool = False,
|
prepend_icons: bool = False,
|
||||||
show_only_dirs: bool = False,
|
show_only_dirs: bool = False,
|
||||||
filter_pattern: Optional[Sequence[str]] = None) -> List[str]:
|
filter_pattern: Optional[Sequence[str]] = None,
|
||||||
|
root_path: str = '') -> List[str]:
|
||||||
"""Get directory contents."""
|
"""Get directory contents."""
|
||||||
files = list()
|
files = list()
|
||||||
dirs = list()
|
dirs = list()
|
||||||
|
@ -83,7 +84,7 @@ def get_dir_contents(
|
||||||
files.append(item)
|
files.append(item)
|
||||||
else:
|
else:
|
||||||
files.append(item)
|
files.append(item)
|
||||||
if has_parent(path):
|
if has_parent(strip_root_path(path, root_path)):
|
||||||
dirs.insert(0, '..')
|
dirs.insert(0, '..')
|
||||||
if prepend_icons:
|
if prepend_icons:
|
||||||
return prepend_dir_icons(sorted(dirs)) + sorted(files)
|
return prepend_dir_icons(sorted(dirs)) + sorted(files)
|
||||||
|
|
Ładowanie…
Reference in New Issue