From 808c7bc0a94ecfd160ee2b257e5feec347829a5e Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Fri, 26 Mar 2021 16:14:35 -0700 Subject: [PATCH] make xmltodict library optional --- jc/parsers/xml.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/jc/parsers/xml.py b/jc/parsers/xml.py index b69a03eb..0484d7eb 100644 --- a/jc/parsers/xml.py +++ b/jc/parsers/xml.py @@ -59,12 +59,18 @@ Examples: ... } """ +import sys import jc.utils -import xmltodict +# check if xml library is installed and fail gracefully if it is not +try: + import xmltodict +except Exception: + jc.utils.error_message('The xmltodict library is not installed.') + sys.exit(1) class info(): - version = '1.2' + version = '1.3' description = 'XML file parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com'