3.0.ipv8.messaging.interfaces.lan_addresses.importshield
Classes
Module Contents
- class 3.0.ipv8.messaging.interfaces.lan_addresses.importshield.Platform(*args, **kwds)
Bases:
enum.EnumPlatform identifier to select where providers should be run.
- ANY = None
- NONE = 0
- WINDOWS = 'Windows'
- LINUX = 'Linux'
- class 3.0.ipv8.messaging.interfaces.lan_addresses.importshield.conditional_import_shield(platf: Platform = Platform.ANY, verbose: bool = False)
Bases:
contextlib.AbstractContextManagerProtect against imports in a context that could segfault when imported in the wrong OS.
This context manager provides two things:
Conditional imports based on platform (
platform.system()).Exception handling and logging.
- right_platform
- module_name
- package_backup
- package_overwritten = False
- verbose
- __enter__() conditional_import_shield
When we enter the context, check if we are running on the right platform.
If we are not on the right platform, we temporarily sabotage the module’s import system.
- __exit__(exctype: type[BaseException] | None, excinst: BaseException | None, exctb: types.TracebackType | None) bool
When we exit the context, unsabotage the import system and log any exceptions.