def safe_to_file(folder, results):
    """
    Receives a list of results (type :class:`Clazz` or :class:`Function`), and put them into the right files in :var:`folder`

    :param folder: Where the files should be in.
    :type  folder: str

    :param results: A list of :class:`Clazz` or :class:`Function` objects, which will be used to calculate the source code.
    :type  results: Union(Clazz, Function)

    """
    functions = []
    message_send_functions = []
    clazzes = {} # "filepath": [Class, Class, ...]

    # split results into functions and classes
    for result in results:
        assert isinstance(result, (Clazz, Function))
        if isinstance(result, Clazz):
            import_path = get_type_path(result.clazz)
            import_path = import_path.rstrip(".")
            file_path = calc_path_and_create_folders(folder, import_path)
            result.filepath = file_path
            if file_path not in clazzes:
                clazzes[file_path] = []
            clazzes[file_path].append(result)
        else:
            assert isinstance(result, Function)
            import_path = "pytgbot.bot."
            file_path = calc_path_and_create_folders(folder, import_path)
            result.filepath = file_path
            functions.append(result)

            if result.name.startswith('send_'):
                import_path = "teleflask_messages."
                file_path = calc_path_and_create_folders(folder, import_path)
                result2 = safe_eval(repr(result), SAVE_VALUES)  # serialize + unserialize = deepcopy
                result2.filepath = file_path
                message_send_functions.append(result2)
            # end if
        # end if
    # end for

    bot_template = get_template("bot.template")
    clazzfile_template = get_template("classfile.template")
    teleflask_messages_template = get_template("teleflask_messages_file.template")
    for path, clazz_list in clazzes.items():
        clazz_imports = set()
        for clazz_ in clazz_list:
            assert isinstance(clazz_, Clazz)
            assert isinstance(clazz_.parent_clazz, Type)
            clazz_imports.add(clazz_.parent_clazz.as_import)
        # end for
        clazz_imports = list(clazz_imports)
        clazz_imports.sort()
        is_sendable = ("sendable" in path)
        try:
            with open(path, "w") as f:
                result = clazzfile_template.render(clazzes=clazz_list, imports=clazz_imports, is_sendable=is_sendable)
                result = result.replace("\t", "    ")
                f.write(result)
                # end with
        except IOError:
            raise  # lol
            # end try
    # end for classes
    if functions:
        txt = bot_template.render(functions=functions)
        with open(functions[0].filepath, "w") as f:
            f.write(txt)
        # end with
    # end if
    if message_send_functions:
        txt = teleflask_messages_template.render(functions=message_send_functions)
        with open(message_send_functions[0].filepath, "w") as f:
            f.write(txt)
Receives a list of results (type :class:`Clazz` or :class:`Function`), and put them into the right files in :var:`folder`

    :param folder: Where the files should be in.
    :type  folder: str

    :param results: A list of :class:`Clazz` or :class:`Function` objects, which will be used to calculate the source code.
    :type  results: Union(Clazz, Function)