[issue22208] tarfile can't add in memory files (reopened)
Lars Gustäbel
report at bugs.python.org
Wed Aug 20 09:37:22 CEST 2014
Lars Gustäbel added the comment:
I don't have an idea how to make it easier and still meet all/most requirements and without cluttering up the api. The way it currently works allows the programmer to control every tiny aspect of a tar member. Maybe it's best to simply add a new entry to the Examples section of the tarfile documentation.
import tarfile, io
with tarfile.open("sample.tar", mode="w") as tar:
t = tarfile.TarInfo("foo")
t.type = tarfile.DIRTYPE
tar.addfile(t)
b = "Hello world!".encode("ascii")
t = tarfile.TarInfo("foo/bar")
t.size = len(b)
tar.addfile(t, io.BytesIO(b))
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22208>
_______________________________________
More information about the Python-bugs-list
mailing list