[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53547] trunk/blender: expose common extensions for image/movie/audio types, since python scripts had to do this internally.

Campbell Barton ideasman42 at gmail.com
Fri Jan 4 04:47:45 CET 2013


Revision: 53547
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53547
Author:   campbellbarton
Date:     2013-01-04 03:47:37 +0000 (Fri, 04 Jan 2013)
Log Message:
-----------
expose common extensions for image/movie/audio types, since python scripts had to do this internally.
- bpy.path.extensions_image
- bpy.path.extensions_movie
- bpy.path.extensions_audio

eg:

  if os.path.splitext(filename)[1].lower() in bpy.path.extensions_image:
      ... we have an image ...

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/bpy/path.py
    trunk/blender/source/blender/python/generic/py_capi_utils.c
    trunk/blender/source/blender/python/generic/py_capi_utils.h
    trunk/blender/source/blender/python/intern/CMakeLists.txt
    trunk/blender/source/blender/python/intern/bpy_interface.c

Modified: trunk/blender/release/scripts/modules/bpy/path.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy/path.py	2013-01-04 03:07:25 UTC (rev 53546)
+++ trunk/blender/release/scripts/modules/bpy/path.py	2013-01-04 03:47:37 UTC (rev 53547)
@@ -30,6 +30,9 @@
     "display_name",
     "display_name_from_filepath",
     "ensure_ext",
+    "extensions_image",
+    "extensions_movie",
+    "extensions_audio",
     "is_subdir",
     "module_names",
     "relpath",
@@ -39,6 +42,10 @@
 import bpy as _bpy
 import os as _os
 
+from _bpy_path import (extensions_audio,
+                       extensions_movie,
+                       extensions_image,
+                       )
 
 def abspath(path, start=None, library=None):
     """

Modified: trunk/blender/source/blender/python/generic/py_capi_utils.c
===================================================================
--- trunk/blender/source/blender/python/generic/py_capi_utils.c	2013-01-04 03:07:25 UTC (rev 53546)
+++ trunk/blender/source/blender/python/generic/py_capi_utils.c	2013-01-04 03:47:37 UTC (rev 53547)
@@ -241,6 +241,23 @@
 	return item;
 }
 
+PyObject *PyC_FrozenSetFromStrings(const char **strings)
+{
+	const char **str;
+	PyObject *ret;
+
+	ret = PyFrozenSet_New(NULL);
+
+	for (str = strings; *str; str++) {
+		PyObject *py_str = PyUnicode_FromString(*str);
+		PySet_Add(ret, py_str);
+		Py_DECREF(py_str);
+	}
+
+	return ret;
+}
+
+
 /* similar to PyErr_Format(),
  *
  * implementation - we cant actually preprend the existing exception,

Modified: trunk/blender/source/blender/python/generic/py_capi_utils.h
===================================================================
--- trunk/blender/source/blender/python/generic/py_capi_utils.h	2013-01-04 03:07:25 UTC (rev 53546)
+++ trunk/blender/source/blender/python/generic/py_capi_utils.h	2013-01-04 03:47:37 UTC (rev 53547)
@@ -33,6 +33,7 @@
 void			PyC_StackSpit(void);
 PyObject *		PyC_ExceptionBuffer(void);
 PyObject *		PyC_Object_GetAttrStringArgs(PyObject *o, Py_ssize_t n, ...);
+PyObject *		PyC_FrozenSetFromStrings(const char **strings);
 PyObject *		PyC_Err_Format_Prefix(PyObject *exception_type_prefix, const char *format, ...);
 void			PyC_FileAndNum(const char **filename, int *lineno);
 void			PyC_FileAndNum_Safe(const char **filename, int *lineno); /* checks python is running */

Modified: trunk/blender/source/blender/python/intern/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/python/intern/CMakeLists.txt	2013-01-04 03:07:25 UTC (rev 53546)
+++ trunk/blender/source/blender/python/intern/CMakeLists.txt	2013-01-04 03:47:37 UTC (rev 53547)
@@ -56,6 +56,7 @@
 	bpy_library.c
 	bpy_operator.c
 	bpy_operator_wrap.c
+	bpy_path.c
 	bpy_props.c
 	bpy_rna.c
 	bpy_rna_anim.c
@@ -76,6 +77,7 @@
 	bpy_library.h
 	bpy_operator.h
 	bpy_operator_wrap.h
+	bpy_path.h
 	bpy_props.h
 	bpy_rna.h
 	bpy_rna_anim.h

Modified: trunk/blender/source/blender/python/intern/bpy_interface.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_interface.c	2013-01-04 03:07:25 UTC (rev 53546)
+++ trunk/blender/source/blender/python/intern/bpy_interface.c	2013-01-04 03:47:37 UTC (rev 53547)
@@ -44,6 +44,7 @@
 #include "bpy.h"
 #include "gpu.h"
 #include "bpy_rna.h"
+#include "bpy_path.h"
 #include "bpy_util.h"
 #include "bpy_traceback.h"
 #include "bpy_intern_string.h"
@@ -212,6 +213,7 @@
 	{(char *)"mathutils", PyInit_mathutils},
 //	{(char *)"mathutils.geometry", PyInit_mathutils_geometry},
 //	{(char *)"mathutils.noise", PyInit_mathutils_noise},
+	{(char *)"_bpy_path", BPyInit__bpy_path},
 	{(char *)"bgl", BPyInit_bgl},
 	{(char *)"blf", BPyInit_blf},
 	{(char *)"bmesh", BPyInit_bmesh},




More information about the Bf-blender-cvs mailing list