def wrapStringToFunctionDef(functionName, scriptString, kwargs=None):
    """Generates function string which then can be compiled and executed

    Example:
    ::

        wrapStringToFunctionDef('test', 'print(a)', {'a': 5})

    Will produce following function:
    ::

        def test(a=5):
            print(a)
    """
    kwargsString = ""
    if kwargs is not None:
        for argname, argValue in kwargs.items():
            if isinstance(argValue, str):
                argValue = "'{}'".format(argValue)
            kwargsString += "{0}={1}, ".format(argname, argValue)
        kwargsString = kwargsString[:-2]

    result = "def {0}({1}):\n".format(functionName, kwargsString)

    for scriptLine in scriptString.split('\n'):
        result += "\t{}".format(scriptLine)
        result += '\n'
    return result