2019-02-09 17:52:51 +00:00
|
|
|
import re
|
2019-10-27 10:19:00 +00:00
|
|
|
from src import IRCLine, utils
|
2019-02-09 17:49:01 +00:00
|
|
|
|
2019-11-22 16:23:30 +00:00
|
|
|
class StdOut(object):
|
|
|
|
def __init__(self, prefix):
|
|
|
|
self.prefix = prefix
|
|
|
|
self._lines = []
|
|
|
|
self.tags = {}
|
2019-06-10 09:45:02 +00:00
|
|
|
self._assured = False
|
|
|
|
|
|
|
|
def assure(self):
|
|
|
|
self._assured = True
|
2019-02-09 17:49:01 +00:00
|
|
|
|
|
|
|
def write(self, text):
|
2019-11-22 16:23:30 +00:00
|
|
|
self.write_lines(
|
|
|
|
text.replace("\r", "").replace("\n\n", "\n").split("\n"))
|
|
|
|
def write_lines(self, lines):
|
|
|
|
self._lines += list(filter(None, lines))
|
|
|
|
|
|
|
|
def get_all(self):
|
|
|
|
return self._lines.copy()
|
|
|
|
def pop(self):
|
|
|
|
return self._lines.pop(0)
|
|
|
|
def insert(self, text):
|
|
|
|
self._lines.insert(0, text)
|
2019-02-09 17:49:01 +00:00
|
|
|
|
|
|
|
def has_text(self):
|
2019-11-22 16:23:30 +00:00
|
|
|
return bool(self._lines)
|
2019-02-09 17:49:01 +00:00
|
|
|
|