Skip to content

Commit

Permalink
trimm output if it's too long
Browse files Browse the repository at this point in the history
  • Loading branch information
jhshi committed Sep 5, 2017
1 parent a84ae3b commit 616f464
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions leetcode/views/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ def __init__(self, quiz, host_view, result, loop = None):
urwid.Frame.__init__(self, self.overlay, footer=footer)

def _append_stdout_if_non_empty(self, list_items):
if len(self.result.get('std_output', '')) > 0:
std_output = self.result.get('std_output', '')
if len(std_output) > 0:
blank = urwid.Divider()
stdout_header = urwid.Text('Stdout:')
stdout = urwid.Text(self.result['std_output'])
if len(std_output) > 100:
std_output = '%s...%s\n(output trimmed due to its length)' %\
(std_output[:90], std_output[-10:])
stdout = urwid.Text(std_output)
list_items.extend([blank, stdout_header, stdout])

def make_success_view(self):
Expand Down

0 comments on commit 616f464

Please sign in to comment.