From aa5ce629626aa9c5d5d532bf466693145922b841 Mon Sep 17 00:00:00 2001 From: Tymoteusz Jankowski Date: Tue, 19 Nov 2019 21:19:34 +0100 Subject: [PATCH 1/2] dvc/dagascii: Use pager instead of AsciiCanvas._do_draw Uses Stdlib's [pydoc](https://docs.python.org/3.8/library/pydoc.html) to draw the output in the interactive mode while doing e.g. `dvc pipeline show ..`. Fixes #2807 --- dvc/dagascii.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dvc/dagascii.py b/dvc/dagascii.py index 6f324b865b..710d023c0c 100644 --- a/dvc/dagascii.py +++ b/dvc/dagascii.py @@ -3,6 +3,8 @@ from __future__ import unicode_literals import math +import os +import pydoc import sys from grandalf.graphs import Edge @@ -61,9 +63,11 @@ def __init__(self, cols, lines): def draw(self): """Draws ASCII canvas on the screen.""" if sys.stdout.isatty(): # pragma: no cover - from asciimatics.screen import Screen - - Screen.wrapper(self._do_draw) + 1/0 + lines = [] + for line in self.canvas: + lines.append("".join(line)) + pydoc.pager(os.linesep.join(lines)) else: for line in self.canvas: print("".join(line)) From b426ed1b6a03b31e5b4d78e72c8150feb6916beb Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 19 Nov 2019 20:24:44 +0000 Subject: [PATCH 2/2] Restyled by black --- dvc/dagascii.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dvc/dagascii.py b/dvc/dagascii.py index 710d023c0c..1e3d363c43 100644 --- a/dvc/dagascii.py +++ b/dvc/dagascii.py @@ -63,7 +63,7 @@ def __init__(self, cols, lines): def draw(self): """Draws ASCII canvas on the screen.""" if sys.stdout.isatty(): # pragma: no cover - 1/0 + 1 / 0 lines = [] for line in self.canvas: lines.append("".join(line))