DirectoryTree Supporting Different File Systems (AWS S3, Google Cloud Storage, Azure Storage) #1719
juftin
started this conversation in
Show and tell
Replies: 1 comment
-
Here it is with Google Cloud Storage and one of Google's public buckets:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been spinning my wheels trying to get the DirectoryTree widget to play nicely with AWS S3 using
boto3
and I realized there's an easier way to do that, with fsspec and s3fs.fsspec
is a "specification for pythonic filesystems" ands3fs
is an implementation offsspec
for AWS S3.fsspec
also has a great extension, universal_pathlib, which extends the fsspec to the pathlib API. It also supports other filesystems like Google Cloud Storage, HDFS, Azure Stoage, and more.Put them all together, and you have a really simple way to extend the DirectoryTree API where the only difference is swapping
pathlib.Path
forupath.UPath
.Finally, run it on an S3 bucket. For this example I found a public S3 bucket using a quick Google search:
pip install "textual[dev]" s3fs universal_pathlib
or if you're more inclined to
pipx
:pipx install "textual[dev]" pipx inject textual s3fs universal_pathlib
textual run "universal_directory_tree.py s3://ryft-public-sample-data/"
Hopefully this is useful for some TUIs out there 🎉
Beta Was this translation helpful? Give feedback.
All reactions