diff --git a/powerline/core.py b/powerline/core.py index 04946d39..b0c8bd3d 100644 --- a/powerline/core.py +++ b/powerline/core.py @@ -5,10 +5,10 @@ class Powerline(object): def __init__(self, segments): '''Create a new Powerline. - Segments that have empty contents and aren't filler segments are + Segments that aren't filler segments and whose contents aren't None are dropped from the segment array. ''' - self.segments = [segment for segment in segments if segment['contents'] or segment['filler']] + self.segments = [segment for segment in segments if segment['contents'] is not None or segment['filler']] def render(self, renderer, width=None): r = renderer(self.segments) diff --git a/powerline/segment.py b/powerline/segment.py index e8955a8b..512ea574 100644 --- a/powerline/segment.py +++ b/powerline/segment.py @@ -6,10 +6,11 @@ from colorscheme import cterm_to_hex def mksegment(contents=None, cterm_fg=False, cterm_bg=False, attr=False, hex_fg=False, hex_bg=False, side='l', draw_divider=True, priority=-1, filler=False): '''Convenience wrapper for segment generation. ''' - try: - contents = unicode(contents or u'') - except UnicodeDecodeError: - contents = contents.decode('utf-8') or u'' + if contents is not None or filler: + try: + contents = unicode(contents or u'') + except UnicodeDecodeError: + contents = contents.decode('utf-8') or u'' return { 'contents': contents,