pycifrw
pycifrw copied to clipboard
`CifFile.WriteOut()` unavoidably prints to stdout
Here's a minimal example:
>>> from CifFile import CifFile, CifBlock
>>> cf['9xyz'] = CifBlock()
>>> x = cf.WriteOut()
Writing 9xyz, <CifFile.CifFile_module.CifBlock object at 0x71f505f7e620>
All blocks output.
If I want to control the output my program shows to the user, this is pretty annoying behavior. At the very least, I think there should be a way to silence these messages (e.g. cf.WriteOut(verbose=False)
). But really, I think they should just be removed.
Looking at the source code, I see that there are a few other messages that get printed when something unexpected happens. I don't have as much issue with these, since they might help catch what would otherwise be silent errors. In a perfect world, though, these messages would probably go through the logging
system.
I did try to make a PR for this, since it's a pretty small issue, but I couldn't figure out how to install the library from source. I've also never encountered *.nw
files before, so I wasn't really sure if I making the right changes. If you can give me some pointers about these issues, though, I'd still be happy to make a PR.
Thanks for this suggestion. I can make the change to the .nw file. nw is noweb, a now no-longer maintained literate programming approach which does not run on Windows, it seems.
I've commented out the offending lines in StarFile.nw
.