Skip to content

Commit

Permalink
formatter: hide block on 'None' string too
Browse files Browse the repository at this point in the history
  • Loading branch information
lasers committed Aug 16, 2018
1 parent 74e298b commit fa201df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions py3status/formatter.py
Expand Up @@ -268,11 +268,11 @@ def get(self, get_params, block):
value = value_ = output.format(**{self.key: value})

if block.commands.not_zero:
valid = value_ not in ['', None, False, '0', '0.0', 0, 0.0]
valid = value_ not in ['', 'None', None, False, '0', '0.0', 0, 0.0]
else:
# '', None, and False are ignored
# numbers like 0 and 0.0 are not.
valid = not (value_ in ['', None] or value_ is False)
valid = not (value_ in ['', 'None', None] or value_ is False)
enough = False
except:
# Exception raised when we don't have the param
Expand Down
5 changes: 5 additions & 0 deletions tests/test_formatter.py
Expand Up @@ -27,6 +27,7 @@
'no': False,
'empty': '',
'None': None,
'None_str': 'None',
'?bad name': 'evil',
u'☂ Very bad name ': u'☂ extremely evil',
'long_str': 'I am a long string though not too long',
Expand Down Expand Up @@ -298,6 +299,10 @@ def test_27():
run_formatter({'format': '{None}', 'expected': '', })


def test_27a():
run_formatter({'format': '[Hi, my name is {None_str}]', 'expected': '', })


def test_28():
run_formatter({'format': '[{None}] hello', 'expected': ' hello', })

Expand Down

0 comments on commit fa201df

Please sign in to comment.