Closed fgrunewald closed 2 years ago
@pckroon or @jbarnoud : of course we can fix it. However, wouldn't it be more sustainable to make the file writers in the same way as the itp write in the sense that the writer does not open the file but gets handed a file_handle or object that has the write attribute.
The quick-fix is super simple though (PR is almost ready). I do like your idea, but it represents a change in API, which is annoying/tricky. I'll open the PR, and we can continue the discussion there.
Here we define open only if deferred file writing is true. However, that means open is undefined if it is not because open is declared as local variable.
https://github.com/marrink-lab/vermouth-martinize/blob/16de64e3f391a6ee1d3ed91ddeaa7352eece8e2e/vermouth/pdb/pdb.py#L583-L586