-
-
Notifications
You must be signed in to change notification settings - Fork 187
Closed
Description
Whenever I work with other libraries that operate on a file inside a filesystem, I always find myself calling path.getsyspath
and passing that into some function of that library.
For example:
from fs.subfs import SubFS
archive_dir: SubFS = self.app.filestorage.makedirs("/parent")
archive_dir.create("archive.zip")
sys_path = archive_dir.getsyspath('archive.zip')
with ZipFile(sys_path, "w", ZIP_DEFLATED) as zip_file:
for match in archive_dir.glob('**/*.csv'):
zip_file.write(archive_dir.getsyspath(match.path))This runs fine. However, if I don't use the getsyspath,
archive = archive_dir.open('archive.zip')
with ZipFile(archive, "w", ZIP_DEFLATED) as zip_file:
for match in archive_dir.glob('**/*.csv'):
zip_file.write(archive_dir.getsyspath(match.path))I get:
TypeError: write() argument must be str, not bytes
I'm very much depending on getsyspath to open files with other libraries. Is there a way to do this without getsyspath?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels