Page Menu
Home
Search
Configure Global Search
Log In
Files
F1425
python_unpack.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Pablo Martin (caedes)
Nov 13 2013, 12:57 PM
Size
10 KB
Subscribers
None
python_unpack.patch
View Options
Index: source/blender/python/api2_2x/Blender.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Blender.c,v
retrieving revision 1.69
diff -u -r1.69 Blender.c
--- source/blender/python/api2_2x/Blender.c 3 Oct 2005 19:36:15 -0000 1.69
+++ source/blender/python/api2_2x/Blender.c 22 Oct 2005 17:51:57 -0000
@@ -53,6 +53,7 @@
#include "BSE_headerbuttons.h"
#include "DNA_screen_types.h" /* for SPACE_VIEW3D */
#include "DNA_userdef_types.h"
+#include "DNA_packedFile_types.h"
#include "EXPP_interface.h" /* for bpy_gethome() */
#include "gen_utils.h"
#include "modules.h"
@@ -102,6 +103,11 @@
static PyObject *Blender_Run( PyObject * self, PyObject * args );
static PyObject *Blender_ShowHelp( PyObject * self, PyObject * args );
static PyObject *Blender_UpdateMenus( PyObject * self);
+static PyObject *Blender_PackAll( PyObject * self);
+static PyObject *Blender_UnpackAll( PyObject * self, PyObject * args);
+static PyObject *Blender_UnpackImage( PyObject * self, PyObject * args);
+static PyObject *Blender_UnpackSample( PyObject * self, PyObject * args);
+static PyObject *Blender_CountPackedFiles( PyObject * self );
extern PyObject *Text3d_Init( void ); /* missing in some include */
@@ -175,6 +181,25 @@
"() - Update the menus where scripts are registered. Only needed for\n\
scripts that save other new scripts in the default or user defined folders.";
+static char Blender_PackAll_doc[] =
+"() - Pack all files.\n\
+All files will packed into the blend file.";
+static char Blender_UnpackAll_doc[] =
+"(mode) - Unpack files.\n\
+All files will be unpacked using specified mode.\n\n\
+(mode) - the unpack mode.";
+static char Blender_UnpackImage_doc[] =
+"(image,mode) - Unpack image with specified mode.\n\n\
+(image) - the image to unpack.\n\
+(mode) - the unpack mode.";
+static char Blender_UnpackSample_doc[] =
+"(sample,mode) - Unpack sample with specified mode.\n\n\
+(sample) - the sample to unpack.\n\
+(mode) - the unpack mode.";
+
+static char Blender_CountPackedFiles_doc[] =
+"() - Returns the number of packed files.";
+
/*****************************************************************************/
/* Python method structure definition. */
/*****************************************************************************/
@@ -187,6 +212,11 @@
{"Save", Blender_Save, METH_VARARGS, Blender_Save_doc},
{"Run", Blender_Run, METH_VARARGS, Blender_Run_doc},
{"ShowHelp", Blender_ShowHelp, METH_VARARGS, Blender_ShowHelp_doc},
+ {"CountPackedFiles", ( PyCFunction ) Blender_CountPackedFiles, METH_NOARGS, Blender_CountPackedFiles_doc},
+ {"PackAll", ( PyCFunction ) Blender_PackAll, METH_NOARGS, Blender_PackAll_doc},
+ {"UnpackAll", Blender_UnpackAll, METH_VARARGS, Blender_UnpackAll_doc},
+ {"UnpackImage", Blender_UnpackImage, METH_VARARGS, Blender_UnpackImage_doc},
+ {"UnpackSample", Blender_UnpackSample, METH_VARARGS, Blender_UnpackSample_doc},
{"UpdateMenus", ( PyCFunction ) Blender_UpdateMenus, METH_NOARGS,
Blender_UpdateMenus_doc},
{NULL, NULL, 0, NULL}
@@ -763,19 +793,114 @@
Py_INCREF( Py_None );
return Py_None;
}
+/*****************************************************************************/
+/* Function: Blender_PackAll */
+/* Python equivalent: Blender.PackAll */
+/*****************************************************************************/
+static PyObject *Blender_PackAll( PyObject * self)
+{
+ packAll();
+ Py_INCREF( Py_None );
+ return Py_None;
+}
+/*****************************************************************************/
+/* Function: Blender_UnpackAll */
+/* Python equivalent: Blender.UnpackAll */
+/*****************************************************************************/
+static PyObject *Blender_UnpackAll( PyObject * self, PyObject *args)
+{
+ int mode;
+ PyArg_ParseTuple( args, "i", &mode );
+ unpackAll(mode);
+ Py_INCREF( Py_None );
+ return Py_None;
+}
/*****************************************************************************/
+/* Function: Blender_UnpackSample */
+/* Python equivalent: Blender.UnpackSample */
+/*****************************************************************************/
+static PyObject *Blender_UnpackSample( PyObject * self, PyObject *args)
+{
+ int mode;
+ struct Sound * snd=NULL;
+ PyObject *pysnd;
+ if( !PyArg_ParseTuple( args, "O!i", Sound_Type, &pysnd, &mode ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "UnpackSample: expected a sound object and an int value, in that order." );
+ if( pysnd != Py_None )
+ {
+ snd=( ( BPy_Sound * ) pysnd )->sound;
+ unpackSample(snd, mode);
+ }
+ Py_INCREF( Py_None );
+ return Py_None;
+}
+/*****************************************************************************/
+/* Function: Blender_UnpackImage */
+/* Python equivalent: Blender.UnpackImage */
+/*****************************************************************************/
+static PyObject *Blender_UnpackImage( PyObject * self, PyObject *args)
+{
+ int mode;
+ struct Image * ima=NULL;
+ PyObject *pyimg;
+ if( !PyArg_ParseTuple( args, "O!i", &Image_Type, &pyimg, &mode ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "UnpackImage: expected an image object and an int value, in that order." );
+ if( pyimg != Py_None )
+ {
+ ima=( ( BPy_Image * ) pyimg )->image;
+ unpackImage(ima, mode);
+ }
+ Py_INCREF( Py_None );
+ return Py_None;
+}
+
+/*****************************************************************************/
+/* Function: Blender_CountPackedFiles */
+/* Python equivalent: Blender.CountPackedFiles */
+/*****************************************************************************/
+static PyObject *Blender_CountPackedFiles( PyObject * self )
+{
+ int nfiles = countPackedFiles();
+ return PyInt_FromLong( nfiles );
+}
+static PyObject *Blender_UnpackModesDict( void )
+{
+ PyObject *UnpackModes = PyConstant_New( );
+ if( UnpackModes ) {
+ BPy_constant *d = ( BPy_constant * ) UnpackModes;
+ PyConstant_Insert( d, "EQUAL", PyInt_FromLong((long)PF_EQUAL) );
+ PyConstant_Insert( d, "DIFFERS",PyInt_FromLong((long)PF_DIFFERS) );
+ PyConstant_Insert( d, "NOFILE", PyInt_FromLong((long)PF_NOFILE) );
+ PyConstant_Insert( d, "WRITE_ORIGINAL", PyInt_FromLong((long)PF_WRITE_ORIGINAL) );
+ PyConstant_Insert( d, "WRITE_LOCAL", PyInt_FromLong((long)PF_WRITE_LOCAL) );
+ PyConstant_Insert( d, "USE_LOCAL", PyInt_FromLong((long)PF_USE_LOCAL) );
+ PyConstant_Insert( d, "USE_ORIGINAL", PyInt_FromLong((long)PF_USE_ORIGINAL) );
+ PyConstant_Insert( d, "KEEP", PyInt_FromLong((long)PF_KEEP) );
+ PyConstant_Insert( d, "NOOP", PyInt_FromLong((long)PF_NOOP) );
+ PyConstant_Insert( d, "ASK", PyInt_FromLong((long)PF_EQUAL) );
+ }
+ return UnpackModes;
+}
+/*****************************************************************************/
/* Function: initBlender */
/*****************************************************************************/
void M_Blender_Init(void)
{
PyObject *module;
- PyObject *dict, *smode, *SpaceHandlers;
+ PyObject *dict, *smode, *SpaceHandlers, *UnpackModes;
module = Py_InitModule3("Blender", Blender_methods,
"The main Blender module");
types_InitAll(); /* set all our pytypes to &PyType_Type */
+
+ // constants for packed files
+ UnpackModes = Blender_UnpackModesDict( );
+ if( UnpackModes )
+ PyModule_AddObject( module, "UnpackModes", UnpackModes );
SpaceHandlers = PyConstant_New();
if (SpaceHandlers) {
Index: source/blender/python/api2_2x/Sound.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Sound.h,v
retrieving revision 1.3
diff -u -r1.3 Sound.h
--- source/blender/python/api2_2x/Sound.h 18 Jul 2005 03:50:37 -0000 1.3
+++ source/blender/python/api2_2x/Sound.h 22 Oct 2005 17:51:57 -0000
@@ -44,6 +44,8 @@
bSound * sound;
} BPy_Sound;
+extern PyTypeObject Sound_Type; /* The Sound PyType Object */
+
/*****************************************************************************/
/* Module Blender.Sound - public functions */
/*****************************************************************************/
Index: source/blender/python/api2_2x/doc/Blender.py
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/doc/Blender.py,v
retrieving revision 1.37
diff -u -r1.37 Blender.py
--- source/blender/python/api2_2x/doc/Blender.py 3 Oct 2005 19:12:11 -0000 1.37
+++ source/blender/python/api2_2x/doc/Blender.py 22 Oct 2005 17:51:58 -0000
@@ -12,6 +12,7 @@
B{New}: L{Run}, L{UpdateMenus}, new options to L{Get}, L{ShowHelp},
L{SpaceHandlers} dictionary.
+L{UnpackModes} dictionary.
Blender
=======
@@ -41,6 +42,12 @@
will exit as soon as it finishes rendering or executing a script
(ex: 'C{blender -b <blender file> -P <script>}'). Try 'C{blender -h}'
for more detailed informations.
+@type UnpackModes: constant dictionary
+@var UnpackModes: dictionary with available unpack modes.
+ - WRITE_ORIGINAL - use files in current directory (create when necessary)
+ - WRITE_LOCAL - write files in current directory (overwrite when necessary)
+ - USE_LOCAL - use files in original location (create when necessary)
+ - USE_ORIGINAL - write files in original location (overwrite when necessary)
@type SpaceHandlers: constant dictionary
@var SpaceHandlers: dictionary with space handler types.
- VIEW3D_EVENT;
@@ -192,6 +199,40 @@
data and will make them accessible via menus.
@note: only scripts that save other new scripts in the default or user
defined folders need to call this function.
+ """
+def UnpackAll (mode):
+ """
+ Unpack all images with specified mode.
+ @param mode: The Mode for unpacking. Must be one of the modes in
+ Blender.UnpackModes dictionary.
+ @type mode: int
+ """
+def PackAll ():
+ """
+ Pack all images.
+ """
+def UnpackImage (image,mode):
+ """
+ Unpack image using specified mode.
+ @param image: The Image to unpack.
+ @type image: Blender Image
+ @param mode: The Mode for unpacking. Must be one of the modes in
+ Blender.UnpackModes dictionary.
+ @type mode: int
+ """
+def UnpackSample (sample,mode):
+ """
+ Unpack sample using specified mode.
+ @param sample: The Sample to unpack.
+ @type sample: Blender Sample
+ @param mode: The Mode for unpacking. Must be one of the modes in
+ Blender.UnpackModes dictionary.
+ @type mode: int
+ """
+
+def Blender_CountPackedFiles():
+ """
+ Returns the number of packed files.
"""
def Quit ():
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
5b/5d/a72cb99502996fcaf06070535fcd
Event Timeline
Log In to Comment