I’m using telnetlib to get a few lines of text (tn = telnetlib).
o = cStringIO.StringIO(tn.read_all())
# this prints the entire text as it should (a few lines)
print o.getvalue()
o.close()
Now, is there a way to search based on a string and replace an entire line in the cStringIO buffer if the string is found?
I did this with files on disk, but it’s not very organised. The code is a mess and I need a lot of temporary files, I need to make a lot of search and replace operations.
small variant on @Sven Marnach’s answer: