The pyedb.internal.checks library#

Summary#

install_message

Generate an installation message for missing dependencies.

check_dependency

Check whether a Python dependency can be imported.

requires_dotnet_dependency

Decorate a method as requiring specific graphics dependencies.

Description#

Provides functions for performing common checks.

Module detail#

checks.install_message(dependency: str | list[str], target: str, level: str = 'method') → str#

Generate an installation message for missing dependencies.

Examples

>>> from pyedb.internal.checks import install_message
>>> install_message("pyvista", "graphics")
checks.check_dependency(dependency: str, target: str = 'all', warning: bool = False) → bool#

Check whether a Python dependency can be imported.

Parameters:
dependencystr

Dependency name or importable module path. Known aliases in _DEPENDENCY_IMPORT_ALIASES are resolved to their import module automatically.

targetstr, optional

PyAEDT installation target to mention in the error message. Defaults to "all".

warningbool, optional

If True, issue a warning instead of raising an error. Default is False.

Returns:
bool

True if the dependency is available, False if unavailable and warning is True.

Raises:
ImportError

If dependency is not available and warning is False.

Examples

>>> from pyedb.internal.checks import check_dependency
>>> check_dependency("pyvista", target="graphics")
checks.requires_dotnet_dependency(*dependencies: str) → collections.abc.Callable[[_F], _F]#

Decorate a method as requiring specific graphics dependencies.

The main goal of this decorator is to isolate the logic around checking graphics dependencies and providing consistent error messages across methods that require such dependencies.

Parameters:
*dependenciesstr

Names of required dependencies (e.g., ‘pyvista’, ‘matplotlib’, ‘vtk’).

Returns:
callable()

Decorated method.

Raises:
ImportError

If any of the required dependencies are not available.

Examples

>>> from pyedb.internal.checks import requires_dotnet_dependency
>>> decorator = requires_dotnet_dependency("ansys-pythonnet", "dotnet")
>>> callable(decorator)
True