I'd like to add the ability to pass in a file-like object instead of a file name for writing to.
Before I start I have some questions:
currently if the output_path paramater of the API calls is False the stdout of wkhtmltopdf is send to the stdout of the python process. Correct?
I'm curious what the use case is for this. It doesn't seem to be a useful feature in a library - is it for debugging?
Keeping this feature complicates support for file-like objects - would you object to me removing it?
subprocess.Popen objects are used for ipc. However the communicate method is only called if self.source.isString() or (self.source.isFile() and self.css) (refactoring the logic slightly).
Why is this? I am guessing that when the source is a url we don't want to block on wkhtmltopdf blocking on network. But what about the case when self.source.isFile() and not self.css ?
what about this block:
if '--quiet' not in args:
while True:
if result.poll() is not None:
break
out = result.stdout.read(1).decode('utf-8')
if out != '':
sys.stdout.write(out)
sys.stdout.flush()
why have you done things this way? I'm guessing that you're only reading a piece at a time so that output will appear on the python processes' stdout as it is produced by wkhtmltopdf .
Also there will only be something produced here when wkhtmltopdf is passed '-' as an output file, right?
I'd like to add the ability to pass in a file-like object instead of a file name for writing to.
Before I start I have some questions:
currently if the
output_pathparamater of the API calls isFalsethe stdout ofwkhtmltopdfis send to the stdout of the python process. Correct?I'm curious what the use case is for this. It doesn't seem to be a useful feature in a library - is it for debugging?
Keeping this feature complicates support for file-like objects - would you object to me removing it?
subprocess.Popenobjects are used for ipc. However thecommunicatemethod is only calledif self.source.isString() or (self.source.isFile() and self.css)(refactoring the logic slightly).Why is this? I am guessing that when the source is a url we don't want to block on
wkhtmltopdfblocking on network. But what about the case whenself.source.isFile() and not self.css?what about this block:
why have you done things this way? I'm guessing that you're only reading a piece at a time so that output will appear on the python processes' stdout as it is produced by
wkhtmltopdf.Also there will only be something produced here when
wkhtmltopdfis passed'-'as an output file, right?