def expand_functions(raw_str):
    def escape(a):
        """Escape user input."""
        if a[0] == "'" and a[-1] == "'":
            a = '"' + a[1:-1]  + '"'

        if a[0] == '"' and a[-1] == '"' and len(a) > 1:
            r = a[1:-1].replace('\\', '\\\\').replace('"', '\\"')
            return a[0] + r + a[-1]

        elif re.match("\d+(\.\d+)?", a):  # is number
            return a

        else:
            raise ValueError

    def callf(match):
        """Call the matched function and inject its return value."""
        fun_name = match.group('fun')
        args = match.group('args')
        args_separator = tube.utils.settings.get('funargs_separator')

        if args:
            argv = [escape(a.strip())
                    for a in args.split(args_separator)]
        else:
            argv = []

        if fun_name:
            if '1' == vim.eval("exists('*{0}')".format(fun_name)):
                try:
                    raw = vim.eval("call('{0}',[{1}])".format(
                        fun_name, ','.join(argv)))
                    return raw.replace('\\', '\\\\')

                except vim.error:
                    pass
            else:
                raise NameError  # unkwown function

    return re.sub('#{(?P<fun>\w*)(\((?P<args>.*)\))?}', callf, raw_str)
Inject the return value of a function in the string where the
dataset/ETHPy150Open chautoni/tube.vim/autoload/tube/utils/misc.py/expand_functions