def save_to_file(destination_filename, append=False):
def decorator_fn(f):<EOL><INDENT>@wraps(f)<EOL>def wrapper_fn(*args, **kwargs):<EOL><INDENT>res = f(*args, **kwargs)<EOL>makedirs(os.path.dirname(destination_filename))<EOL>mode = "<STR_LIT:a>" if append else "<STR_LIT:w>"<EOL>with open(destination_filename, mode) as text_file:<EOL><INDENT>text_file.write(res)<EOL><DEDENT>return res<EOL><DEDENT>return wrapper_fn<EOL><DEDENT>return decorator_fn<EOL>
Save the output value to file.