def _get_class_for_interface(interface):
    """
    Returns the main bus class for the given interface.

    :raises:
        NotImplementedError if the interface is not known
    :raises:
        ImportError     if there was a problem while importing the
                        interface or the bus class within that
    """
    # Find the correct backend
    try:
        module_name, class_name = BACKENDS[interface]
    except KeyError:
        raise NotImplementedError("CAN interface '{}' not supported".format(interface))

    # Import the correct interface module
    try:
        module = importlib.import_module(module_name)
    except Exception as e:
        raise ImportError(
            "Cannot import module {} for CAN interface '{}': {}".format(module_name, interface, e)
        )

    # Get the correct class
    try:
        bus_class = getattr(module, class_name)
    except Exception as e:
        raise ImportError(
            "Cannot import class {} from module {} for CAN interface '{}': {}"
                .format(class_name, module_name, interface, e)
        )

    return bus_class
def _get_class_for_interface ( interface ) : try : module_name , class_name = BACKENDS [ interface ] except KeyError : raise NotImplementedError ( "CAN interface '{}' not supported" . format ( interface ) ) try : module = importlib . import_module ( module_name ) except Exception as e : raise ImportError ( "Cannot import module {} for CAN interface '{}': {}" . format ( module_name , interface , e ) ) try : bus_class = getattr ( module , class_name ) except Exception as e : raise ImportError ( "Cannot import class {} from module {} for CAN interface '{}': {}" . format ( class_name , module_name , interface , e ) ) return bus_class
Returns the main bus class for the given interface.

    :raises:
        NotImplementedError if the interface is not known
    :raises:
        ImportError     if there was a problem while importing the
                        interface or the bus class within that