"""Logic for dealing with cwltool as an optional dependency.
Use this as the import interface for cwltool and just call
:func:`ensure_cwltool_available` before using any of the imported
functionality at runtime.
"""
import re
try:
import requests
except ImportError:
requests = None
try:
from cwltool import (
main,
workflow,
job,
process,
pathmapper,
)
except (ImportError, SyntaxError):
# Drop SyntaxError once cwltool supports Python 3
main = None
workflow = None
job = None
process = None
pathmapper = None
try:
from cwltool.context import LoadingContext # Introduced in cwltool 1.0.20180615183820
except (ImportError, SyntaxError):
LoadingContext = None
try:
from cwltool import load_tool
except (ImportError, SyntaxError):
load_tool = None
try:
import shellescape
except ImportError:
shellescape = None
try:
import schema_salad
except (ImportError, SyntaxError):
# Drop SyntaxError once schema_salad supports Python 3
schema_salad = None
try:
from schema_salad import ref_resolver
except (ImportError, SyntaxError):
ref_resolver = None
needs_shell_quoting = re.compile(r"""(^$|[\s|&;()<>\'"$@])""").search
__all__ = (
'main',
'ref_resolver',
'load_tool',
'LoadingContext',
'workflow',
'process',
'pathmapper',
'ensure_cwltool_available',
'schema_salad',
'shellescape',
'needs_shell_quoting',
)