Skip to content

Commit

Permalink
Remove some items from key/value dump (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
amelchio authored Aug 18, 2019
1 parent 615afac commit 9f058f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions eternalegypt/eternalegypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Information:
current_band = attr.ib(default=None)
cell_id = attr.ib(default=None)
sms = attr.ib(factory=list)
everything = attr.ib(factory=dict)
items = attr.ib(factory=dict)


def autologin(function, timeout=TIMEOUT):
Expand Down Expand Up @@ -251,10 +251,13 @@ def _build_information(self, data):
result.sms.append(element)
result.sms.sort(key=lambda sms: sms.id)

result.everything = {
result.items = {
key.lower(): value
for key, value in flatten_json.flatten(data, '.').items()
if value != {}
and not re.search(r'\.\d+\.', key)
and not re.search(r'\.end$', key)
and key.lower() not in ('webd.adminpassword', 'session.sectoken', 'wifi.guest.passphrase', 'wifi.passphrase')
}

return result
Expand Down
2 changes: 1 addition & 1 deletion examples/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async def get_information():
print("cell_id: {}".format(result.cell_id))
else:
key = sys.argv[3]
print("{}: {}".format(key, result.everything.get(key)))
print("{}: {}".format(key, result.items.get(key)))

await modem.logout()
except eternalegypt.Error:
Expand Down

0 comments on commit 9f058f2

Please sign in to comment.