Py-Driver: add 'self' option
[blender.git] / source / blender / python / intern / bpy_library_write.c
index 478e5f7829568904a6ab82c1cce242407837e93f..f582cebb2601daa8b6f144a55bbb00842460082e 100644 (file)
@@ -35,7 +35,7 @@
 #include "BLI_path_util.h"
 
 #include "BKE_library.h"
-#include "BKE_blender.h"
+#include "BKE_blendfile.h"
 #include "BKE_global.h"
 #include "BKE_main.h"
 #include "BKE_report.h"
@@ -60,19 +60,21 @@ PyDoc_STRVAR(bpy_lib_write_doc,
 "\n"
 "   :arg filepath: The path to write the blend-file.\n"
 "   :type filepath: string\n"
-"   :arg datablocks: data-blocks (:class:`bpy.types.ID` instances).\n"
-"   :type datablocks: sequence\n"
-"   :arg relative_remap: When Truem, remap the paths relative to the current blend-file.\n"
+"   :arg datablocks: set of data-blocks (:class:`bpy.types.ID` instances).\n"
+"   :type datablocks: set\n"
+"   :arg relative_remap: When True, remap the paths relative to the current blend-file.\n"
 "   :type relative_remap: bool\n"
 "   :arg fake_user: When True, data-blocks will be written with fake-user flag enabled.\n"
 "   :type fake_user: bool\n"
+"   :arg compress: When True, write a compressed blend file.\n"
+"   :type compress: bool\n"
 );
 static PyObject *bpy_lib_write(PyObject *UNUSED(self), PyObject *args, PyObject *kwds)
 {
        static const char *kwlist[] = {
                "filepath", "datablocks",
                /* optional */
-               "relative_remap", "fake_user",
+               "relative_remap", "fake_user", "compress",
                NULL,
        };
 
@@ -80,15 +82,16 @@ static PyObject *bpy_lib_write(PyObject *UNUSED(self), PyObject *args, PyObject
        const char *filepath;
        char filepath_abs[FILE_MAX];
        PyObject *datablocks = NULL;
-       bool use_relative_remap = false, use_fake_user = false;
+       bool use_relative_remap = false, use_fake_user = false, use_compress = false;
 
        if (!PyArg_ParseTupleAndKeywords(
                args, kwds,
-               "sO!|$O&O&:write", (char **)kwlist,
+               "sO!|$O&O&O&:write", (char **)kwlist,
                &filepath,
                &PySet_Type, &datablocks,
                PyC_ParseBool, &use_relative_remap,
-               PyC_ParseBool, &use_fake_user))
+               PyC_ParseBool, &use_fake_user,
+               PyC_ParseBool, &use_compress))
        {
                return NULL;
        }
@@ -100,6 +103,10 @@ static PyObject *bpy_lib_write(PyObject *UNUSED(self), PyObject *args, PyObject
                write_flags |= G_FILE_RELATIVE_REMAP;
        }
 
+       if (use_compress) {
+               write_flags |= G_FILE_COMPRESS;
+       }
+
        BLI_strncpy(filepath_abs, filepath, FILE_MAX);
        BLI_path_abs(filepath_abs, G.main->name);