def import_optional(mod_name):
 try:
  return import_module(mod_name)
 except ImportError:
  pass
 except Exception:
  msg = 'Failed to import optional module `{}`'.format(mod_name)
  logger.exception(msg)

def import_optional ( mod_name ) : try : return import_module ( mod_name ) except ImportError : pass except Exception : msg = 'Failed to import optional module `{}`' . format ( mod_name ) logger . exception ( msg )
attempt to import an optional dependency .