Skip to content
This repository has been archived by the owner on Apr 29, 2023. It is now read-only.

Commit

Permalink
allow floating point values
Browse files Browse the repository at this point in the history
  • Loading branch information
mkinney committed Mar 25, 2022
1 parent 0d56e47 commit a8808b8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 9 additions & 1 deletion meshtastic_flasher/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from meshtastic_flasher.util import (get_path, populate_tag_in_firmware_dropdown,
tag_to_version, tags_to_versions, get_tags,
download_if_zip_does_not_exist, unzip_if_necessary,
check_if_newer_version)
check_if_newer_version, zero_if_blank)


def test_get_path():
Expand Down Expand Up @@ -185,3 +185,11 @@ def test_check_if_newer_version_when_on_alpha_and_pre_and_match(patched_requests
with patch('meshtastic_flasher.version.__version__', '1.3alpha.5'):
result = check_if_newer_version()
assert result is False


def test_zero_if_blank():
"""Test zero_if_blank()"""
assert zero_if_blank("") == "0"
assert zero_if_blank("0") == "0"
assert zero_if_blank("1") == "1"
assert zero_if_blank("1.1") == "1.1"
5 changes: 4 additions & 1 deletion meshtastic_flasher/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ def zero_if_blank(some_input):
retval = 0
else:
try:
retval = int(some_input)
if '.' in some_input:
retval = float(some_input)
else:
retval = int(some_input)
except:
pass
return f'{retval}'
Expand Down

0 comments on commit a8808b8

Please sign in to comment.