Open richardjgowers opened 5 years ago
We set the default mode="rt"
https://github.com/MDAnalysis/mdanalysis/blob/89b2299e3ae8ab548fcc932b72eb6128b2be0463/package/MDAnalysis/lib/util.py#L333 and then say that we ignore everything beyond the first letter – that's rather inconsistent :-p.
Yes, should be clarified / consistent / tested, but useful that it is actually apparently possible for Windows of course.
We also explicitly use 'rb' for the TRZ reader. I think I remember the 'rt' default was set because of python3 because some compressed files were open in byte mode. It starts to be an old change so I can be wrong.
Can we define clearly what needs to happen? Something like
ValueError
for everything elseAnything else?
That sounds good to me On Mon, Nov 26, 2018 at 7:19 PM, Oliver Beckstein notifications@github.com wrote:
Can we define clearly what needs to happen? Something like
- allow 'rb' and 'wb' (and 'rt' and 'wt') in addition to 'r', 'w', 'a'.
- document the allowed modes
- add checks that only allowed modes are accepted and raise ValueError for everything else
- add tests
Anything else?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/MDAnalysis/mdanalysis/issues/2130#issuecomment-441850137, or mute the thread https://github.com/notifications/unsubscribe-auth/AI0jBx6cplTFxVgTuCI3Femdsggdra9Uks5uzIUNgaJpZM4YJwgA .
MDAnalysis.lib.util.anyopen
(and its context manager cousinopenany
) currently opens files/archives/streams seamlessly and is used in most Readers. It accepts a mode argument like the regularopen
function, but this mode doesn't explicitly support more complex modes ier+
.In PR #2127 we started to require using
mode='rb'
to get ascii reading working in Windows environments. This works currently, but isn't technically supported, ie the api foranyopen
doesn't say this should work (and it's therefore not tested to work either).These more complicated modes should be accepted & enforced (or at least a subset which we need to use, ie
'rb'
for backends (ie files/archives/streams) which support this).