Improve the behaviour of yamlget.py when run with python2

(cherry picked from commit 9e72266705)
This commit is contained in:
Mark Andrews
2020-06-05 08:43:17 +10:00
parent 28a940fe69
commit 0c23582ffd

View 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)