idaholab / MontePy

MontePy is the most user friendly Python library (API) to read, edit, and write MCNP input files.
https://www.montepy.org/
MIT License
32 stars 7 forks source link

Add support for reading from non-file steams #519

Closed MicahGale closed 1 month ago

MicahGale commented 2 months ago

Is your feature request related to a problem? Please describe.

It would be nice (mainly in testing) to do:

fh = io.StringIO()
fh.write(...)
fh.seek(0)
problem = montepy.read_input(fh)

Describe the solution you'd like montepy.read_input should accept file streams.

Describe alternatives you've considered None that I can think of.

Additional context This is mostly for testing.

tjlaboss commented 2 months ago

The soulmate of #493

MicahGale commented 2 months ago

☯️

MicahGale commented 2 months ago

Exactly. This is why I needed it.

MicahGale commented 2 months ago

Turns out I forgot to implement this.