[issue22208] tarfile can't add in memory files (reopened)

2016-02-19 Thread Roundup Robot
Roundup Robot added the comment: New changeset 94a94deaf06a by Martin Panter in branch '3.5': Issues #22468, #21996, #22208: Clarify gettarinfo() and TarInfo usage https://hg.python.org/cpython/rev/94a94deaf06a New changeset 9d5217aaea13 by Martin Panter in branch '2.7': Issues #22468, #21996, #

[issue22208] tarfile can't add in memory files (reopened)

2015-04-19 Thread Martin Panter
Martin Panter added the comment: In Issue 22468, I posted a patch which encourages using TarInfo directly, and hopefully clarifies that gettarinfo() is only for OS files. I think that should cover the documentation aspect of this bug, although an enhancement to synthesize TarInfo objects for r

[issue22208] tarfile can't add in memory files (reopened)

2015-03-23 Thread Martin Panter
Martin Panter added the comment: If you read the documentation it is clear that gettarfile() requires an OS file, so won’t work with an internal Python-only file object. Maybe the documentation could be tweaked, but I don’t think the gettarfile() implementation should be changed. To me the who

[issue22208] tarfile can't add in memory files (reopened)

2014-08-21 Thread Lars Gustäbel
Lars Gustäbel added the comment: Please provide a patch which allows easy addition of file-like objects (not only io.BytesIO) and directories, preferably hard and symbolic links, too. It would be nice to still be able to change attributes of a TarInfo before addition. Please also add tests. -

[issue22208] tarfile can't add in memory files (reopened)

2014-08-20 Thread Mark Grandi
Mark Grandi 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. That is what i mentioned in my original post, a lot of the time users just _don't care_ about a lot of the stuff that a tar archive can store (p

[issue22208] tarfile can't add in memory files (reopened)

2014-08-20 Thread Lars Gustäbel
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 Ex

[issue22208] tarfile can't add in memory files (reopened)

2014-08-19 Thread Antoine Pitrou
Antoine Pitrou added the comment: The example given by Lars shows that it's not that easy to come up with the right code. Why not make it easier? -- nosy: +pitrou ___ Python tracker ___

[issue22208] tarfile can't add in memory files (reopened)

2014-08-19 Thread Mark Grandi
Mark Grandi added the comment: I was just thinking that if os.stat fails, then you try getting the size by just calling len() on it, as stuff like io.BytesIO and io.StringIO will respond to that. But if we are not changing the behavior of the API, at the very least there needs to be documenta

[issue22208] tarfile can't add in memory files (reopened)

2014-08-19 Thread Lars Gustäbel
Lars Gustäbel added the comment: tarfile needs to know the size of a file object beforehand because the tar header is written first followed by the file object's data. If the file object is not based on a real file descriptor, tarfile cannot simply use os.fstat() but the user has to pass the s

[issue22208] tarfile can't add in memory files (reopened)

2014-08-18 Thread Mark Grandi
Mark Grandi added the comment: I still don't see why TarFile.add() can't be changed to accept a file like object so users don't have to fumble around with a TarInfo object when they just want add a file like object, and don't care about the permission bits and whatnot. It also says un the TarI

[issue22208] tarfile can't add in memory files (reopened)

2014-08-18 Thread R. David Murray
Changes by R. David Murray : -- nosy: +r.david.murray ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://m

[issue22208] tarfile can't add in memory files (reopened)

2014-08-16 Thread Lars Gustäbel
Lars Gustäbel added the comment: Why overcomplicate things? import io, tarfile with tarfile.open("foo.tar", mode="w") as tar: b = "hello world!".encode("utf-8") t = tarfile.TarInfo("helloworld.txt") t.size = len(b) # this is crucial tar.addfile(t, io.BytesIO(b)) My answer to

[issue22208] tarfile can't add in memory files (reopened)

2014-08-15 Thread Ned Deily
Changes by Ned Deily : -- nosy: +lars.gustaebel ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.py

[issue22208] tarfile can't add in memory files (reopened)

2014-08-15 Thread Mark Grandi
New submission from Mark Grandi: So I ran into this problem today, where near impossible to create a tarfile.TarFile object, then add files to the archive, when the files are in memory file-like objects (like io.BytesIO, io.StringIO, etc) code example: ### import tarfile, io