An improvement to this pattern would making the file format known at instantiation, either explicitly or inferred.
gfile = FileWrapper(egridfile) # infers fileformat from suffix and/or contents
# declares the file format -- should it be checked against the suffix and/or contents?
gfile = FileWrapper(egridfile, format="egrid")
This is fairly easy to implement when reading files but some consideration is needed when creating a FileWrapper instance to write a file.
The FileWrapper class has had a few methods to detect file formats but this should likely be something that is generalized on initialization.
For the moment (with a pending PR) to get the file format one must manually collect it, but it can also be proposed:
An improvement to this pattern would making the file format known at instantiation, either explicitly or inferred.
This is fairly easy to implement when reading files but some consideration is needed when creating a FileWrapper instance to write a file.
(The keyword might also be
fformat
)