From bc915250604f6cfe3f367aab8cabf23422839aba Mon Sep 17 00:00:00 2001 From: Kamel Malki Date: Sun, 11 Sep 2022 22:31:18 +0200 Subject: [PATCH] Add filtering function --- main.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/main.py b/main.py index 6079bb1..b041938 100644 --- a/main.py +++ b/main.py @@ -47,3 +47,16 @@ def print_datagram(): print(f'{key} : {value}') pprint(datagram_response) + + +def get_attribute(geo_zone, attribute_key): + with open('datagram.json', mode='r', encoding='utf-8') as json_datagram: + load_datagram: dict = json.load(json_datagram) + if geo_zone in load_datagram["pops"].keys() and attribute_key in load_datagram["pops"][geo_zone]: + print(f'geo_zone : {geo_zone}, {attribute_key} : {load_datagram["pops"][geo_zone][attribute_key]}') + return load_datagram["pops"][geo_zone][attribute_key].strip() + else: + print("Error with key value input") + return None + +