You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description of problem
I have successfully imported rst2pdf as module and called the main() function.
But I am not sure if rst2pdf is supposed to be used in such a way, since it calls sys.exit(). I can catch the respective exception by:
Hey @liquidsigma, I've never used it like that as I only use it from the command line. However, I'm keen to support your use-case as best we can. We're not planning on changing anything related to sys.exit() calls at the moment, but is there a reasonably simple change that we could make that would help make your use-case easier? I'm happy to accept a PR that supports using rst2pdf as a python module more easily as long as it doesn't break the cli usage.
Thanks @akrabat for the fast response!
Actually I'm quite happy with rst2pdf as it is, since I can capture the exception raised by sys.exit() and based on the return_code decide what to do in my app. Maybe a code snippet in the documentation regarding the use of rst2pdf as module would already be enough for most users:
import rst2pdf.createpdf
try:
rst2pdf.createpdf.main(["input.rst","output.pdf"]) # on regular exit this calls sys.exit() with return code 0
except SystemExit as e:
if e.code == 0:
pass # rst2pdf completed without any errors
else:
pass # rst2pdf completed with error(s)
Description of problem
I have successfully imported rst2pdf as module and called the
main()
function.But I am not sure if rst2pdf is supposed to be used in such a way, since it calls sys.exit(). I can catch the respective exception by:
Will my work around also work in future versions of rst2pdf?
Or is it the intention of rst2pdf to be solely used on the command line via rst2pdf.exe?
Using rst2pdf via import, and the code shown above, enables me to easily bundle my app using Pyinstaller.
🖥 Versions
python -V
Python 3.10.3
pip freeze | grep rst2pdf
rst2pdf==0.99
pip freeze | grep reportlab
reportlab==3.6.12
Which operating system are you using?
Windows 10
The text was updated successfully, but these errors were encountered: