-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC Allow for io.StringIO inputs to certain modules #576
Conversation
There is a new 'buffer' data_kind which is intended for io.StringIO stream data. This 'buffer' data is passed into `legend` via an intermediate file created using the helper tempfile_from_buffer function.
9d6fd85
to
d79a0c8
Compare
8e63b74
to
06ee891
Compare
@dr-glenn, do you want to try this branch using Happy to receive any feedback before we merge this. If it's good, we might get this in for the upcoming PyGMT v0.2.0 release 😁 |
|
I'm a pretty new user of To be fair, we'll probably need to refactor this hacky implementation (writing to a tempfile and having GMT read that file) to use |
Yes, that's another point. Without this PR, users just need to add a few lines of codes (maybe two or three) to write strings into a temporary file, and pass the file name to legend(), text() or any other modules. But here you add several lines of codes to support it, and these codes are most likely to be removed in the future. Not sure if it's really worth the complexity. |
Fair point, the code here is really just a convenience function to simplify maybe 4-5 lines of code: pygmt/pygmt/helpers/tempfile.py Lines 150 to 155 in 06ee891
As for whether it's worth it, there are some GMT Supplemental Modules that don't quite support virtualfiles yet (e.g. |
@weiji14 I think it's time to refactor this PR, so that all functions can accept |
Description of proposed changes
Make a
tempfile_from_buffer
backend function forio.StringIO
inputs. Will be useful for modules where:Figure.legend
's 'spec' option (see also Allow Figure.legend to read from StringIO #571)x2sys_cross
(see also Wrap x2sys_init and x2sys_cross #546 (comment))This is implemented as the 'hacky' Option 1 at #571 (comment).
Happy to discuss about the actual implementation details, such as:
See also:
Fixes #571
Reminders
make format
andmake check
to make sure the code follows the style guide.doc/api/index.rst
.