def _getSmartIndenter(indenterName, qpart, indenter):
    """Get indenter by name.
    Available indenters are none, normal, cstyle, haskell, lilypond, lisp, python, ruby, xml
    Indenter name is not case sensitive
    Raise KeyError if not found
    indentText is indentation, which shall be used. i.e. '\t' for tabs, '    ' for 4 space symbols
    """
    indenterName = indenterName.lower()

    if indenterName in ('haskell', 'lilypond'):  # not supported yet
        logger.warning('Smart indentation for %s not supported yet. But you could be a hero who implemented it' % indenterName)
        from qutepart.indenter.base import IndentAlgNormal as indenterClass
    elif 'none' == indenterName:
        from qutepart.indenter.base import IndentAlgBase as indenterClass
    elif 'normal' == indenterName:
        from qutepart.indenter.base import IndentAlgNormal as indenterClass
    elif 'cstyle' == indenterName:
        from qutepart.indenter.cstyle import IndentAlgCStyle as indenterClass
    elif 'python' == indenterName:
        from qutepart.indenter.python import IndentAlgPython as indenterClass
    elif 'ruby' == indenterName:
        from qutepart.indenter.ruby import IndentAlgRuby as indenterClass
    elif 'xml' == indenterName:
        from qutepart.indenter.xmlindent import IndentAlgXml as indenterClass
    elif 'haskell' == indenterName:
        from qutepart.indenter.haskell import IndenterHaskell as indenterClass
    elif 'lilypond' == indenterName:
        from qutepart.indenter.lilypond import IndenterLilypond as indenterClass
    elif 'lisp' == indenterName:
        from qutepart.indenter.lisp import IndentAlgLisp as indenterClass
    elif 'scheme' == indenterName:
        from qutepart.indenter.scheme import IndentAlgScheme as indenterClass
    else:
        raise KeyError("Indenter %s not found" % indenterName)

    return indenterClass(qpart, indenter)
def execute_rpc(self, audit_name, rpc_code, response_queue, args, kwargs):
        """
        Honor a remote procedure call request from a plugin.

        :param audit_name: Name of the audit requesting the call.
        :type audit_name: str

        :param rpc_code: RPC code.
        :type rpc_code: int

        :param response_queue: Response queue identity.
        :type response_queue: str

        :param args: Positional arguments to the call.
        :type args: tuple

        :param kwargs: Keyword arguments to the call.
        :type kwargs: dict
        """
        try:

            # Get the implementor for the RPC code.
            # Raise NotImplementedError if it's not defined.
            try:
                target, blocking = self.__rpcMap[rpc_code]
            except KeyError:
                raise NotImplementedError(
                    "RPC code not implemented: %r" % rpc_code)

            # If it's a blocking call...
            if blocking:

                # Run the implementor in a new thread.
                thread = Thread(
                    target = self._execute_rpc_implementor_background,
                    args = (
                        Config._context,
                        audit_name,
                        target,
                        response_queue,
                        args, kwargs),
                )
                thread.daemon = True
                thread.start()

            # If it's a non-blocking call...
            else:

                # Call the implementor directly.
                self.execute_rpc_implementor(
                    audit_name, target, response_queue, args, kwargs)

        # Catch exceptions and send them back.
        except Exception:
            if response_queue:
                error = self.prepare_exception(*sys.exc_info())
                try:
                    self.orchestrator.messageManager.send(
                        response_queue, (False, error))
                except IOError:
                    import warnings
                    warnings.warn("RPC caller died!")
                    pass