translate(f=None, *, output=TranslateOutput.code, **kwargs)
        Decorator that turns a function into a shellcode emitting function.

        Arguments:
            f(callable): The function to decorate. If ``f`` is ``None`` a
                decorator will be returned instead.
            output(~pwnypack.shellcode.base.BaseEnvironment.TranslateOutput): The output
                format the shellcode function will produce.
            **kwargs: Keyword arguments are passed to shellcode environment
                constructor.

        Returns:
            A decorator that will translate the given function into a
            shellcode generator

        Examples:
            >>> from pwny import *
            >>> @sc.LinuxX86Mutable.translate
            ... def shellcode():
            ...     sys_exit(0)

            >>> @sc.LinuxX86Mutable.translate(output=1)
            ... def shellcode():
            ...     sys_exit(0)

def translate(cls, f=None, output=0, **kwargs):
        """translate(f=None, *, output=TranslateOutput.code, **kwargs)
        Decorator that turns a function into a shellcode emitting function.

        Arguments:
            f(callable): The function to decorate. If ``f`` is ``None`` a
                decorator will be returned instead.
            output(~pwnypack.shellcode.base.BaseEnvironment.TranslateOutput): The output
                format the shellcode function will produce.
            **kwargs: Keyword arguments are passed to shellcode environment
                constructor.

        Returns:
            A decorator that will translate the given function into a
            shellcode generator

        Examples:
            >>> from pwny import *
            >>> @sc.LinuxX86Mutable.translate
            ... def shellcode():
            ...     sys_exit(0)

            >>> @sc.LinuxX86Mutable.translate(output=1)
            ... def shellcode():
            ...     sys_exit(0)
        """

        def decorator(f):
            @functools.wraps(f)
            def proxy(*p_args, **p_kwargs):
                env = cls(**kwargs)
                result = translate(env, f, *p_args, **p_kwargs)
                if output == cls.TranslateOutput.code:
                    return env.assemble(result)
                elif output == cls.TranslateOutput.assembly:
                    return env.target, env.compile(result)
                else:
                    return env, result
            return proxy

        if f is None:
            return decorator
        else:
            return decorator(f)