def hsdev_command(async = False, timeout = None, is_list = False):
    def wrap_function(fn):
        def wrapped(self, *args, **kwargs):
            wait_flag = kwargs.pop('wait', not async)
            timeout_arg = kwargs.pop('timeout', timeout)
            on_resp = kwargs.pop('on_response', None)
            on_not = kwargs.pop('on_notify', None)
            on_err = kwargs.pop('on_error', None)
            on_res_part = kwargs.pop('on_result_part', None)
            split_res = kwargs.pop('split_result', on_res_part is not None)

            (name_, opts_, on_result_) = fn(self, *args, **kwargs)

            if is_list and split_res:
                result = []
                def on_notify(n):
                    if 'result-part' in n:
                        rp = on_result_([n['result-part']])[0]
                        call_callback(on_res_part, rp)
                        result.append(rp)
                    else:
                        call_callback(on_not, n)
                def on_response(r):
                    on_resp(result)

                opts_.update({'split-result': None}) # FIXME: Is this option still used?
                r = self.call(
                    name_,
                    opts_,
                    on_response = on_response if on_resp else None,
                    on_notify = on_notify,
                    on_error = on_err,
                    wait = wait_flag,
                    timeout = timeout_arg)
                if wait_flag:
                    return result
                return r

            else:
                def on_response(r):
                    on_resp(on_result_(r))
                r = self.call(
                    name_,
                    opts_,
                    on_response = on_response if on_resp else None,
                    on_notify = on_not,
                    on_error = on_err,
                    wait = wait_flag,
                    timeout = timeout_arg)
                if wait_flag:
                    return on_result_(r)
                return r
        return wrapped
    return wrap_function
dataset/ETHPy150Open SublimeHaskell/SublimeHaskell/hsdev.py/hsdev_command/original