From 9f058f21ec5e809697cb85e83139814b993f1835 Mon Sep 17 00:00:00 2001 From: Anders Melchiorsen Date: Sun, 18 Aug 2019 19:34:21 +0200 Subject: [PATCH] Remove some items from key/value dump (#17) --- eternalegypt/eternalegypt.py | 7 +++++-- examples/status.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/eternalegypt/eternalegypt.py b/eternalegypt/eternalegypt.py index 85d8b92..ce8f07c 100644 --- a/eternalegypt/eternalegypt.py +++ b/eternalegypt/eternalegypt.py @@ -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): @@ -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 diff --git a/examples/status.py b/examples/status.py index 04c3e30..6491653 100755 --- a/examples/status.py +++ b/examples/status.py @@ -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: