Lines Matching full:stream

52 class Stream(object):  class
61 stdout = Stream(sys.stdout)
62 stderr = Stream(sys.stderr)
77 def _set_valid_stream(self, stream): argument
78 if stream is None:
80 return stream
82 def _write(self, text, stream): argument
103 # No tags. Just write the text to the current stream and return.
107 stream = self._set_valid_stream(stream)
108 stream.py.write(text.replace(r"\>", ">"))
144 self._stack[-1](before, lock=_null_lock, stream=stream)
150 colors[color](within, lock=_null_lock, stream=stream)
155 self._stack[-1](after, lock=_null_lock, stream=stream)
157 def flush(self, stream): argument
158 stream = self._set_valid_stream(stream)
159 stream.py.flush()
161 def auto(self, text, stream=None, lock=_lock): argument
163 stream = self._set_valid_stream(stream)
182 fn(line, stream=stream, lock=_null_lock)
185 self.default(line, stream=stream, lock=_null_lock)
195 def red_impl(self, text, stream=None, **kwargs): argument
202 def yellow_impl(self, text, stream=None, **kwargs): argument
209 def green_impl(self, text, stream=None, **kwargs): argument
216 def blue_impl(self, text, stream=None, **kwargs): argument
223 def default_impl(self, text, stream=None, **kwargs): argument
243 for stream in (None, self.__class__.stderr):
244 perm[0][0]("stdout " if stream is None else "stderr ", stream)
246 fn(string, stream)
247 self.default("\n", stream)
267 for stream in (None, self.__class__.stderr):
268 stream_name = "stdout" if stream is None else "stderr"
269 fn("{} {}\n".format(stream_name, text), stream)
274 def red_impl(self, text, stream=None, **kwargs): argument
275 self._write("[R]{}[/R]".format(text), stream)
277 def yellow_impl(self, text, stream=None, **kwargs): argument
278 self._write("[Y]{}[/Y]".format(text), stream)
280 def green_impl(self, text, stream=None, **kwargs): argument
281 self._write("[G]{}[/G]".format(text), stream)
283 def blue_impl(self, text, stream=None, **kwargs): argument
284 self._write("[B]{}[/B]".format(text), stream)
286 def default_impl(self, text, stream=None, **kwargs): argument
287 self._write("[D]{}[/D]".format(text), stream)
291 stream = Stream(StringIO())
292 o.red("hello", stream)
293 self.assertEqual(stream.py.getvalue(), "[R]hello[/R]")
297 stream = Stream(StringIO())
298 o.yellow("hello", stream)
299 self.assertEqual(stream.py.getvalue(), "[Y]hello[/Y]")
303 stream = Stream(StringIO())
304 o.green("hello", stream)
305 self.assertEqual(stream.py.getvalue(), "[G]hello[/G]")
309 stream = Stream(StringIO())
310 o.blue("hello", stream)
311 self.assertEqual(stream.py.getvalue(), "[B]hello[/B]")
315 stream = Stream(StringIO())
316 o.default("hello", stream)
317 self.assertEqual(stream.py.getvalue(), "[D]hello[/D]")
321 stream = Stream(StringIO())
323 o.auto("bar\n", stream)
324 o.auto("foo\n", stream)
325 o.auto("baz\n", stream)
327 stream.py.getvalue(), "[D]bar\n[/D][R]foo\n[/R][D]baz\n[/D]"
330 stream = Stream(StringIO())
331 o.auto("bar\nfoo\nbaz\n", stream)
333 stream.py.getvalue(), "[D]bar\n[/D][R]foo\n[/R][D]baz\n[/D]"
336 stream = Stream(StringIO())
337 o.auto("barfoobaz\nbardoobaz\n", stream)
339 stream.py.getvalue(), "[R]barfoobaz\n[/R][D]bardoobaz\n[/D]"
343 stream = Stream(StringIO())
344 o.auto("barfoobaz\nbardoobaz\n", stream)
346 stream.py.getvalue(), "[R]barfoobaz\n[/R][G]bardoobaz\n[/G]"
354 stream = Stream(StringIO())
355 o.auto("foo\nbar\nbaz\n", stream)
357 stream.py.getvalue(), "[R]foo\n[/R][G]bar\n[/G][D]baz\n[/D]"
360 stream = Stream(StringIO())
361 o.auto("foo\nbar\nbaz\n", stream)
363 stream.py.getvalue(), "[R]foo\n[/R][D]bar\n[/D][D]baz\n[/D]"
366 stream = Stream(StringIO())
367 o.yellow("<a>foo</>bar<a>baz</>", stream)
369 stream.py.getvalue(),
375 stream = Stream(StringIO())
376 o.auto("<r>hi</>", stream)
377 self.assertEqual(stream.py.getvalue(), "[D][D][/D][R]hi[/R][D][/D][/D]")
379 stream = Stream(StringIO())
380 o.auto("<r><y>a</>b</>c", stream)
382 stream.py.getvalue(),
387 o.auto("<r>hi", stream)
390 o.auto("hi</>", stream)
393 o.auto("<r><y>hi</>", stream)
396 o.auto("<r><y>hi</><r></>", stream)
399 o.auto("</>hi<r>", stream)