program_converter_manager
¶
ProgramConverterAlreadyRegisteredError
¶
Raised when attempting to re-register an already registered converter.
ProgramConverterError
¶
Base exception for program converter-related errors.
ProgramConverterManager
¶
ProgramConverterManager()
Manage ProgramConverters for converting between different programs.
Provides functionality to register, retrieve, and check converters. Converters are objects that perform conversions from a specific source program to a target program.
fetch_converter
¶
fetch_converter(from_lib: str, to_lib: str) -> ProgramConverter
Retrieve a converter from the specified program to another program.
Parameters:
-
from_lib(str) –The name of the source program.
-
to_lib(str) –The name of the target program.
Returns:
-
ProgramConverter(ProgramConverter) –An instance of the converter corresponding to the specified source and target programs. If the source and target are the same, it returns an instance of PassThroughProgramConverter.
Raises:
-
ProgramConverterNotFoundError–Raised when the requested converter is not found.
has_converter
¶
has_converter(from_lib: str, to_lib: str) -> bool
Check if a converter exists between the specified devices.
Parameters:
-
from_lib(str) –The name of the source device (string)
-
to_lib(str) –The name of the target device (string)
Returns:
-
bool(bool) –True if a converter exists, False otherwise
register_converter
¶
register_converter(from_lib: str, to_lib: str, converter: ProgramConverter, *, allow_override: bool = False) -> None
Register a converter between the specified programs.
Parameters:
-
from_lib(str) –The name of the source program.
-
to_lib(str) –The name of the target program.
-
converter(ProgramConverter) –The converter instance to register.
-
allow_override(bool, default:False) –When False, prevents overwriting existing registrations. Defaults to False.
Raises:
-
ProgramConverterAlreadyRegisteredError–Raised when attempting to re-register an already registered converter and allow_override is False.
ProgramConverterNotFoundError
¶
Raised when the requested converter is not found.