From 4d394015f458f284d052ce2c1a0c8492916c5b3e Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Fri, 26 Mar 2021 16:10:28 -0700 Subject: [PATCH] make ruamel.yaml library optional --- jc/parsers/yaml.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/jc/parsers/yaml.py b/jc/parsers/yaml.py index 51efe5af..8248b082 100644 --- a/jc/parsers/yaml.py +++ b/jc/parsers/yaml.py @@ -71,12 +71,18 @@ Examples: } ] """ +import sys import jc.utils -from ruamel.yaml import YAML +# check if yaml library is installed and fail gracefully if it is not +try: + from ruamel.yaml import YAML +except Exception: + jc.utils.error_message('The ruamel.yaml library is not installed.') + sys.exit(1) class info(): - version = '1.2' + version = '1.3' description = 'YAML file parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com'