From 5400f1ed812f94bf93d35efd883274316818fa40 Mon Sep 17 00:00:00 2001
From: Auke Klazema <klazema@astron.nl>
Date: Thu, 21 Apr 2022 09:49:25 +0000
Subject: [PATCH] changed setu_annotation

---
 .../tangostationcontrol/clients/snmp_client.py         | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/tangostationcontrol/tangostationcontrol/clients/snmp_client.py b/tangostationcontrol/tangostationcontrol/clients/snmp_client.py
index 1aa527e91..9055789f5 100644
--- a/tangostationcontrol/tangostationcontrol/clients/snmp_client.py
+++ b/tangostationcontrol/tangostationcontrol/clients/snmp_client.py
@@ -60,18 +60,16 @@ class SNMP_client(CommClient):
             index (optional) the index if the value thats being read from is a table.
         """
 
-        # check if the 'mib' and 'name' keys are present
-        if 'mib' in annotation and 'name' in annotation:
+        try:
             mib = annotation["mib"]
             name = annotation["name"]
 
             # SNMP has tables that require an index number to access them. regular non-table variable have an index of 0
             idx = annotation.get('index', 0)
 
-        else:
-            raise ValueError(f"SNMP attribute annotation requires a dict argument with both a 'name' and 'mib' key. Instead got: {annotation}")
-
-        return mib, name, idx
+            return mib, name, idx
+        except KeyError:
+            raise ValueError(f"SNMP attribute annotation requires a dict argument with both a 'name' and 'mib' key. Instead got: {annotation}")        
 
     def setup_value_conversion(self, attribute):
         """
-- 
GitLab