jankatins / knitpy

knitpy: Elegant, flexible and fast dynamic report generation with python
https://github.com/jankatins/knitpy
Other
368 stars 29 forks source link

change back directory on error #16

Closed jankatins closed 3 years ago

jankatins commented 9 years ago

Currently, if you use Knitpy().render(...) and an exception is raised (e.g. pandoc can't write to a file because it is opened in the pdf reader), the current working dir is changed to the dir where the pymd file was.

Catch the error, change back and reraise?

thatcher commented 9 years ago

I ran into this issue too and agree knitpy should always put you back where you executed the code. If all we want to do is put the user back and allow the pypandoc error through we dont even need to catch and reraise, just use a try/finally.