Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions 6 meshtastic/mesh_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ def showInfo(self, file=sys.stdout):
nodes = ""
if self.nodes:
for n in self.nodes.values():
# when the TBeam is first booted, it sometimes shows the 'raw' data
# when the TBeam is first booted, it sometimes shows the raw data
# so, we will just remove any raw keys
n2 = remove_keys_from_dict('raw', n)
n2 = remove_keys_from_dict('decode', n2)
keys_to_remove = ('raw', 'decoded', 'payload')
n2 = remove_keys_from_dict(keys_to_remove, n)

# if we have 'macaddr', re-format it
if 'macaddr' in n2['user']:
Expand Down
17 changes: 17 additions & 0 deletions 17 meshtastic/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,23 @@ def test_remove_keys_from_dict():
assert remove_keys_from_dict(('b'), {'a':1, 'b':2}) == {'a':1}


@pytest.mark.unit
def test_remove_keys_from_dict_multiple_keys():
"""Test remove_keys_from_dict()"""
keys = ('a', 'b')
adict = {'a': 1, 'b': 2, 'c': 3}
assert remove_keys_from_dict(keys, adict) == {'c':3}


@pytest.mark.unit
def test_remove_keys_from_dict_nested():
"""Test remove_keys_from_dict()"""
keys = ('b')
adict = {'a': {'b': 1}, 'b': 2, 'c': 3}
exp = {'a': {}, 'c': 3}
assert remove_keys_from_dict(keys, adict) == exp


@pytest.mark.unitslow
def test_Timeout_not_found():
"""Test Timeout()"""
Expand Down
16 changes: 11 additions & 5 deletions 16 meshtastic/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,18 @@ def support_info():


def remove_keys_from_dict(keys, adict):
"""Return a dictionary without some keys in it."""
newdict = adict
"""Return a dictionary without some keys in it.
Will removed nested keys.
"""
for key in keys:
if key in adict:
del newdict[key]
return newdict
try:
del adict[key]
except:
pass
for val in adict.values():
if isinstance(val, dict):
remove_keys_from_dict(keys, val)
return adict


def hexstr(barray):
Expand Down
2 changes: 1 addition & 1 deletion 2 setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# This call to setup() does all the work
setup(
name="meshtastic",
version="1.2.50",
version="1.2.51",
description="Python API & client shell for talking to Meshtastic devices",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.