]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Improve the behaviour of yamlget.py when run with python2
authorMark Andrews <marka@isc.org>
Thu, 4 Jun 2020 22:43:17 +0000 (08:43 +1000)
committerMark Andrews <marka@isc.org>
Fri, 5 Jun 2020 00:01:08 +0000 (10:01 +1000)
bin/tests/system/digdelv/yamlget.py

index 5e35c5658aa9cd21a2ef537be18bba5267d8f042..77ac0f04a365bb434060be59d2ce89736d653835 100644 (file)
@@ -13,7 +13,9 @@ import sys
 
 try:
     import yaml
-except (ModuleNotFoundError, ImportError):
+# flake8: noqa: E722
+# pylint: disable=bare-except
+except:
     print("No python yaml module, skipping")
     sys.exit(1)
 
@@ -25,6 +27,10 @@ with open(sys.argv[1], "r") as f:
             except ValueError:
                 pass
 
-            item = item[key]
+            try:
+                item = item[key]
+            except KeyError:
+                print('Key "' + key + '" not found.')
+                sys.exit(1)
 
         print(item)