mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
use LibraryNotInstalled exception instead of exiting via sys.exit
This commit is contained in:
@ -65,19 +65,13 @@ Examples:
|
|||||||
...
|
...
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
import sys
|
|
||||||
import jc.utils
|
import jc.utils
|
||||||
# check if xml library is installed and fail gracefully if it is not
|
from jc.exceptions import LibraryNotInstalled
|
||||||
try:
|
|
||||||
import xmltodict
|
|
||||||
except Exception:
|
|
||||||
jc.utils.error_message('The xmltodict library is not installed.')
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
"""Provides parser metadata (version, author, etc.)"""
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
version = '1.4'
|
version = '1.5'
|
||||||
description = 'XML file parser'
|
description = 'XML file parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -121,6 +115,12 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
Dictionary. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
|
# check if xml library is installed and fail gracefully if it is not
|
||||||
|
try:
|
||||||
|
import xmltodict
|
||||||
|
except Exception:
|
||||||
|
raise LibraryNotInstalled('The xmltodict library is not installed.')
|
||||||
|
|
||||||
if not quiet:
|
if not quiet:
|
||||||
jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible)
|
||||||
|
|
||||||
|
@ -79,19 +79,13 @@ Examples:
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
import sys
|
|
||||||
import jc.utils
|
import jc.utils
|
||||||
# check if yaml library is installed and fail gracefully if it is not
|
from jc.exceptions import LibraryNotInstalled
|
||||||
try:
|
|
||||||
from ruamel.yaml import YAML
|
|
||||||
except Exception:
|
|
||||||
jc.utils.error_message('The ruamel.yaml library is not installed.')
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
"""Provides parser metadata (version, author, etc.)"""
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
version = '1.4'
|
version = '1.5'
|
||||||
description = 'YAML file parser'
|
description = 'YAML file parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -135,6 +129,12 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries representing the YAML documents.
|
List of Dictionaries representing the YAML documents.
|
||||||
"""
|
"""
|
||||||
|
# check if yaml library is installed and fail gracefully if it is not
|
||||||
|
try:
|
||||||
|
from ruamel.yaml import YAML
|
||||||
|
except Exception:
|
||||||
|
raise LibraryNotInstalled('The ruamel.yaml library is not installed.')
|
||||||
|
|
||||||
if not quiet:
|
if not quiet:
|
||||||
jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user