Message239090
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 whole point of it is to call fstat() on the file and fill in the TarInfo attributes appropriately.
Instead, perhaps an enhancement could be made that allowed something like this:
metadata = TarInfo.make_file('helloworld.txt', len(b))
tarFileObj.addfile(metadata, io.BytesIO(b))
The corresponding TarInfo class could grow new presets looking something like:
class TarInfo:
@classmethod
def make_file(cls, name, size): # Name and size are mandatory
self = cls(name)
self.type = REGTYPE
self.size = size
self.mtime = None # Force addfile() to set it to some default time.time() value
self.mode = 0o644
return self
@classmethod
def make_executable(cls, name, size):
...
self.mode = 0o755
...
@classmethod
def make_directory(cls, name):
...
self.type = DIRTYPE
...
def make_hard_link(cls, name, target)
def make_symlink(cls, name, target)
def make_block_device(cls, name, major, minor) # Set undocumented attributes
def make_char_device(cls, name, major, minor) |
|
Date |
User |
Action |
Args |
2015-03-24 03:36:29 | martin.panter | set | recipients:
+ martin.panter, lars.gustaebel, pitrou, r.david.murray, markgrandi |
2015-03-24 03:36:29 | martin.panter | set | messageid: <1427168189.35.0.848097805056.issue22208@psf.upfronthosting.co.za> |
2015-03-24 03:36:29 | martin.panter | link | issue22208 messages |
2015-03-24 03:36:28 | martin.panter | create | |
|