Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2006-09-21 22:25:40 +0400
committerCampbell Barton <ideasman42@gmail.com>2006-09-21 22:25:40 +0400
commitd82f1f5f91a8d1b19f1451479e1e82ab15744356 (patch)
treea3f11e1127449c818146bf38167c5f97cc8e10b5 /source/blender/python/api2_2x
parent95c185c4c5be57fb0c83b1045605ca8ac37e5284 (diff)
from looking at patch 4934 made all user preference paths settable with Blender.Set('val', data), also added exception errors which were on the todo.
image.filename was being limited to FILE_MAXDIR rather then FILE_MAXDIR + FILE_MAXFILE when setting.
Diffstat (limited to 'source/blender/python/api2_2x')
-rw-r--r--source/blender/python/api2_2x/Blender.c79
-rw-r--r--source/blender/python/api2_2x/Image.c8
-rw-r--r--source/blender/python/api2_2x/doc/Blender.py10
3 files changed, 65 insertions, 32 deletions
diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c
index 7d89c0a41e3..e4cbd0dab0d 100644
--- a/source/blender/python/api2_2x/Blender.c
+++ b/source/blender/python/api2_2x/Blender.c
@@ -234,29 +234,59 @@ PyObject *g_blenderdict;
/*****************************************************************************/
static PyObject *Blender_Set( PyObject * self, PyObject * args )
{
- char *name;
+ char *name, *dir = NULL;
PyObject *arg;
int framenum;
- if( !PyArg_ParseTuple( args, "sO", &name, &arg ) ) {
- /* TODO: Do we need to generate a nice error message here? */
- return ( NULL );
- }
+ if( !PyArg_ParseTuple( args, "sO", &name, &arg ) )
+ return EXPP_ReturnPyObjError( PyExc_ValueError, "expected 2 args, where the first is always a string" );
if( StringEqual( name, "curframe" ) ) {
- if( !PyArg_Parse( arg, "i", &framenum ) ) {
- /* TODO: Do we need to generate a nice error message here? */
- return ( NULL );
- }
-
+ if( !PyArg_Parse( arg, "i", &framenum ) )
+ return ( NULL ); /* TODO: Do we need to generate a nice error message here? */
G.scene->r.cfra = (short)framenum;
-
update_for_newframe( );
- } else {
+
+ } else if (StringEqual( name , "uscriptsdir" ) ) {
+ if ( !PyArg_Parse( arg , "s" , &dir ))
+ return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
+ BLI_strncpy(U.pythondir, dir, FILE_MAXDIR);
+ } else if (StringEqual( name , "yfexportdir" ) ) {
+ if ( !PyArg_Parse( arg , "s" , &dir ))
+ return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
+ BLI_strncpy(U.yfexportdir, dir, FILE_MAXDIR);
+ } else if (StringEqual( name , "fontsdir" ) ) {
+ if ( !PyArg_Parse( arg , "s" , &dir ))
+ return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
+ BLI_strncpy(U.fontdir, dir, FILE_MAXDIR);
+ } else if (StringEqual( name , "texturesdir" ) ) {
+ if ( !PyArg_Parse( arg , "s" , &dir ))
+ return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
+ BLI_strncpy(U.textudir, dir, FILE_MAXDIR);
+ } else if (StringEqual( name , "texpluginsdir" ) ) {
+ if ( !PyArg_Parse( arg , "s" , &dir ))
+ return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
+ BLI_strncpy(U.plugtexdir, dir, FILE_MAXDIR);
+ } else if (StringEqual( name , "seqpluginsdir" ) ) {
+ if ( !PyArg_Parse( arg , "s" , &dir ))
+ return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
+ BLI_strncpy(U.plugseqdir, dir, FILE_MAXDIR);
+ } else if (StringEqual( name , "renderdir" ) ) {
+ if ( !PyArg_Parse( arg , "s" , &dir ))
+ return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
+ BLI_strncpy(U.renderdir, dir, FILE_MAXDIR);
+ } else if (StringEqual( name , "soundsdir" ) ) {
+ if ( !PyArg_Parse( arg , "s" , &dir ))
+ return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
+ BLI_strncpy(U.sounddir, dir, FILE_MAXDIR);
+ } else if (StringEqual( name , "tempdir" ) ) {
+ if ( !PyArg_Parse( arg , "s" , &dir ))
+ return EXPP_ReturnPyObjError( PyExc_ValueError, "expected a string" );
+ BLI_strncpy(U.tempdir, dir, FILE_MAXDIR);
+ } else
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
- "bad request identifier" ) );
- }
- return ( EXPP_incr_ret( Py_None ) );
+ "value given is not a blender setting" ) );
+ Py_RETURN_NONE;
}
/*****************************************************************************/
@@ -496,8 +526,7 @@ static PyObject *Blender_Quit( PyObject * self )
exit_usiblender( ); /* renames last autosave to quit.blend */
- Py_INCREF( Py_None );
- return Py_None;
+ Py_RETURN_NONE;
}
/**
@@ -610,8 +639,7 @@ static PyObject *Blender_Load( PyObject * self, PyObject * args )
}
}
- Py_INCREF( Py_None );
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *Blender_Save( PyObject * self, PyObject * args )
@@ -673,8 +701,7 @@ static PyObject *Blender_Save( PyObject * self, PyObject * args )
disable_where_script( 0 );
- Py_INCREF( Py_None );
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *Blender_ShowHelp(PyObject *self, PyObject *args)
@@ -721,7 +748,7 @@ static PyObject *Blender_ShowHelp(PyObject *self, PyObject *args)
Blender_Run(self, arglist);
Py_DECREF(arglist);
- return EXPP_incr_ret(Py_None);
+ Py_RETURN_NONE;
}
static PyObject *Blender_Run(PyObject *self, PyObject *args)
@@ -784,7 +811,7 @@ static PyObject *Blender_Run(PyObject *self, PyObject *args)
if (!is_blender_text) free_libblock(&G.main->text, text);
- return EXPP_incr_ret(Py_None);
+ Py_RETURN_NONE;
}
static PyObject * Blender_UpdateMenus( PyObject * self )
@@ -796,8 +823,7 @@ static PyObject * Blender_UpdateMenus( PyObject * self )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"invalid scripts dir");
- Py_INCREF( Py_None );
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *Blender_RemoveFakeuser(PyObject *self, PyObject *args)
@@ -823,8 +849,7 @@ static PyObject *Blender_RemoveFakeuser(PyObject *self, PyObject *args)
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"given object does not have a Blender ID");
- Py_INCREF( Py_None );
- return Py_None;
+ Py_RETURN_NONE;
}
/*****************************************************************************/
diff --git a/source/blender/python/api2_2x/Image.c b/source/blender/python/api2_2x/Image.c
index b280fd83931..bd3c76c1ee5 100644
--- a/source/blender/python/api2_2x/Image.c
+++ b/source/blender/python/api2_2x/Image.c
@@ -1036,17 +1036,17 @@ static PyObject *Image_setFilename( BPy_Image * self, PyObject * args )
char *name;
int namelen = 0;
- /* max len is FILE_MAXDIR = 160 chars like done in DNA_image_types.h */
+ /* max len is FILE_MAXDIR == 160, FILE_MAXFILE == 80 chars like done in DNA_image_types.h */
if( !PyArg_ParseTuple( args, "s#", &name, &namelen ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected a string argument" ) );
- if( namelen >= FILE_MAXDIR )
+ if( namelen >= FILE_MAXDIR + FILE_MAXFILE )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "string argument is limited to 160 chars at most" ) );
+ "string argument is limited to 240 chars at most" ) );
- PyOS_snprintf( self->image->name, FILE_MAXDIR * sizeof( char ), "%s",
+ PyOS_snprintf( self->image->name, (FILE_MAXDIR + FILE_MAXFILE) * sizeof( char ), "%s",
name );
Py_RETURN_NONE;
diff --git a/source/blender/python/api2_2x/doc/Blender.py b/source/blender/python/api2_2x/doc/Blender.py
index eea61dad92d..1b25999fa8c 100644
--- a/source/blender/python/api2_2x/doc/Blender.py
+++ b/source/blender/python/api2_2x/doc/Blender.py
@@ -60,7 +60,15 @@ def Set (request, data):
@type request: string
@param request: The setting to change:
- 'curframe': the current animation frame
- @type data: int
+ - 'uscriptsdir': user scripts dir
+ - 'yfexportdir': yafray temp xml storage dir
+ - 'fontsdir': font dir
+ - 'texturesdir': textures dir
+ - 'seqpluginsdir': sequencer plugin dir
+ - 'renderdir': default render output dir
+ - 'soundsdir': sound dir
+ - 'tempdir': temp file storage dir
+ @type data: int or string
@param data: The new value.
"""