Author martin.panter
Recipients martin.panter, mgorny, remi.lapeyre
Date 2018-12-02.09:04:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1543741460.08.0.788709270274.issue35227@psf.upfronthosting.co.za>
In-reply-to
Content
If something like your “addbuffer” method existed, then you won’t need to get the size first, right? We don’t need the changes in “gettarinfo” for “addbuffer” to be useful.

BTW have you considered returning a file writer rather than accepting a file reader? Similar to ZipFile.open(..., mode='w'). It would be a bit more complicated to implement, but also more flexible for the user:

# File downloaded with “urlopen”, also possible with TarFile.addbuffer API:
with tf.get_file_writer(download_tarinfo) as writer:
    shutil.copyfileobj(urlopen_response, writer)

# SVG file generated on the fly, encoded with UTF-8 and Gzip compressed; not possible with “addbuffer”:
writer = tf.get_file_writer(svgz_tarinfo)
gzip_writer = gzip.GzipFile(fileobj=writer, mode='w')
with io.TextIOWrapper(gzip_writer, 'utf-8') as text_writer:
    svg = xml.sax.saxutils.XMLGenerator(text_writer, 'UTF-8')
    svg.startDocument()
    ...
History
Date User Action Args
2018-12-02 09:04:20martin.pantersetrecipients: + martin.panter, mgorny, remi.lapeyre
2018-12-02 09:04:20martin.pantersetmessageid: <1543741460.08.0.788709270274.issue35227@psf.upfronthosting.co.za>
2018-12-02 09:04:20martin.panterlinkissue35227 messages
2018-12-02 09:04:19martin.pantercreate