PlasmaCalcs.tools.imports.ImportFailed
- class PlasmaCalcs.tools.imports.ImportFailed(modulename, additional_error_message='', *, err=None, locals=None, abbrv=None)
Bases:
objectset modules which fail to import to be instances of this class;initialize with modulename, additional_error_message.when attempting to call or access any attribute of the ImportFailed object,raises ImportFailedError(’. ‘.join(modulename, additional_error_message)).Also, if DEFAULTS.IMPORT_FAILURE_WARNINGS, make warning immediately when initialized.- err: None, Exception, or str
- if provided, include str(err) when raising ImportFailedError
- locals: None or dict
- if provided, set locals[‘__pdoc__’][modulename] = Falseif abbrv provided, use abbrv instead of modulename.Use this to tell pdoc to skip the ImportFailed instance when creating docs pages.
- abbrv: None or str
- if provided, set locals[‘__pdoc__’][abbrv] = False
Example:try:import h5netcdfexcept ImportError as err:h5netcdf = ImportFailed(‘h5netcdf’, ‘This module is required for compressing data.’, err=err)h5netcdf.load(…) # << attempt to use h5netcdf# if h5netcdf was imported successfully, it will work fine.# if h5netcdf failed to import, this error will be raised:ImportFailedError: h5netcdf. This module is required for compressing data.
The original ImportError error was: No module named ‘h5netcdf’- __init__(modulename, additional_error_message='', *, err=None, locals=None, abbrv=None)
Methods
__init__(modulename[, ...])error_message()