Merge pull request #1211 from efiop/master

dagascii: import asciimatics only when needed
This commit is contained in:
Ruslan Kuprieiev
2018-10-12 00:11:06 +03:00
committed by GitHub
+3 -3
View File
@@ -2,9 +2,6 @@ import sys
import math
import select
from asciimatics.screen import Screen
from asciimatics.event import KeyboardEvent
from grandalf.graphs import Vertex, Edge, Graph
from grandalf.layouts import SugiyamaLayout
from grandalf.routing import route_with_lines, EdgeViewer
@@ -22,12 +19,15 @@ class AsciiCanvas(object):
def draw(self):
if sys.stdout.isatty(): # pragma: no cover
from asciimatics.screen import Screen
Screen.wrapper(self._do_draw)
else:
for line in self.canvas:
print(''.join(line))
def _do_draw(self, screen): # pragma: no cover
from asciimatics.event import KeyboardEvent
offset_x = 0
offset_y = 0
smaxrow, smaxcol = screen.dimensions