Skip to content

Commit

Permalink
Refs #76 - only print 'You should restart:' if we actually have somet…
Browse files Browse the repository at this point in the history
…hing to print
  • Loading branch information
sean797 committed Mar 23, 2017
1 parent c9332c8 commit 5d1447e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ def test_default_note_only(self):
]))
view.render()
self.assertEquals(self.out.getvalue(), (
"You should restart:\n"
"There are:\n"
" - 2 processes requiring restart of your session (i.e. Logging out & Logging in again)\n"
" - 1 processes requiring reboot\n"
Expand Down
10 changes: 7 additions & 3 deletions tracer/views/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ def next(self, index):
return True
return False

def has_content(self):
"""Return True if at least one block's content is not empty"""
return self.next(-1)
def has_content_and_title(self):
"""Return True if at least one block's content & title is not empty"""
for block in self.args.blocks[0:]:
if block["content"] and "title" in block.keys():
if block["title"]:
return True
return False
2 changes: 1 addition & 1 deletion tracer/views/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ def note_content():

view = BlocksView(self.out)
view.assign("blocks", blocks)
if view.has_content():
if view.has_content_and_title():
self.print(_("You should restart:"))
view.render()

0 comments on commit 5d1447e

Please sign in to comment.