From 6873beb82397155d50bf577d75155643c2df0ea7 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Mon, 7 Dec 2020 20:08:39 -0800 Subject: [PATCH] Rename output -> stdout, add stderr. --- voussoirkit/pipeable.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/voussoirkit/pipeable.py b/voussoirkit/pipeable.py index df899d9..8d22afe 100644 --- a/voussoirkit/pipeable.py +++ b/voussoirkit/pipeable.py @@ -130,12 +130,21 @@ def input( continue yield line -def output(line, end='\n'): - sys.stdout.write(line) +def _output(stream, line, end): + stream.write(line) if not line.endswith(end): - sys.stdout.write(end) + stream.write(end) if not OUT_PIPE: - sys.stdout.flush() + stream.flush() + +def stdout(line, end='\n'): + _output(sys.stdout, line, end) + +def stderr(line, end='\n'): + _output(sys.stderr, line, end) + +# backwards compat +output = stdout def go(args=None, *input_args, **input_kwargs): '''