I need to make a string to be read by bibtexparser
's parsing_read
. As far as I understood the module, it only reads file, not stream, so I have done:
text = "Some text"
with open("/tmp/bibtmp.bib", "w") as bibfile:
bibfile.write(text)
self.parsing.parsing_read("/tmp/bibtmp.bib")
But, I am trying to make it read the string, and trying io.StringIO
module as:
fakefile = io.StringIO("SomeText")
self.parsing.parsing_read(fakefile)
which is giving error(from the self.parsing.parsing_read, which opens the file):
TypeError: invalid file: <_io.StringIO object at 0x7fb4d6537ca8>
So, obviously, fakefile is io.StringIO
, and not a Fake
file.
Am I understanding io.StringIO
's purpose wrong? or just doing it wrong?