[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34596] trunk/blender: Pythons path functions - os.walk().
Campbell Barton
ideasman42 at gmail.com
Tue Feb 1 05:24:48 CET 2011
Revision: 34596
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34596
Author: campbellbarton
Date: 2011-02-01 04:24:47 +0000 (Tue, 01 Feb 2011)
Log Message:
-----------
Pythons path functions - os.walk(). os.path.exists(). etc support bytes for paths as well as strings, support this with blender/rna too.
- bpy.data.*.load() functions were only accepting UTF-8 paths.
- rna functions/properties now accept byte values rather then strings for file paths.
- bpy.path.resolve_ncase now supports byte objects.
Modified Paths:
--------------
trunk/blender/release/scripts/modules/bpy/path.py
trunk/blender/source/blender/makesrna/intern/rna_image_api.c
trunk/blender/source/blender/makesrna/intern/rna_main_api.c
trunk/blender/source/blender/makesrna/intern/rna_scene_api.c
trunk/blender/source/blender/python/generic/py_capi_utils.c
Modified: trunk/blender/release/scripts/modules/bpy/path.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy/path.py 2011-02-01 02:54:29 UTC (rev 34595)
+++ trunk/blender/release/scripts/modules/bpy/path.py 2011-02-01 04:24:47 UTC (rev 34596)
@@ -129,7 +129,7 @@
import os
def _ncase_path_found(path):
- if path == "" or os.path.exists(path):
+ if not path or os.path.exists(path):
return path, True
filename = os.path.basename(path) # filename may be a directory or a file
Modified: trunk/blender/source/blender/makesrna/intern/rna_image_api.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_image_api.c 2011-02-01 02:54:29 UTC (rev 34595)
+++ trunk/blender/source/blender/makesrna/intern/rna_image_api.c 2011-02-01 04:24:47 UTC (rev 34596)
@@ -198,7 +198,7 @@
func= RNA_def_function(srna, "save_render", "rna_Image_save_render");
RNA_def_function_ui_description(func, "Save image to a specific path using a scenes render settings");
RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
- parm= RNA_def_string(func, "filepath", "", 0, "", "Save path.");
+ parm= RNA_def_string_file_path(func, "filepath", "", 0, "", "Save path.");
RNA_def_property_flag(parm, PROP_REQUIRED);
RNA_def_pointer(func, "scene", "Scene", "", "Scene to take image parameters from");
Modified: trunk/blender/source/blender/makesrna/intern/rna_main_api.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_main_api.c 2011-02-01 02:54:29 UTC (rev 34595)
+++ trunk/blender/source/blender/makesrna/intern/rna_main_api.c 2011-02-01 04:24:47 UTC (rev 34596)
@@ -516,7 +516,7 @@
/*
func= RNA_def_function(srna, "add_image", "rna_Main_add_image");
RNA_def_function_ui_description(func, "Add a new image.");
- parm= RNA_def_string(func, "filepath", "", 0, "", "File path to load image from.");
+ parm= RNA_def_string_file_path(func, "filepath", "", 0, "", "File path to load image from.");
RNA_def_property_flag(parm, PROP_REQUIRED);
parm= RNA_def_pointer(func, "image", "Image", "", "New image.");
RNA_def_function_return(func, parm);
@@ -805,7 +805,7 @@
func= RNA_def_function(srna, "load", "rna_Main_images_load");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Load a new image into the main database");
- parm= RNA_def_string(func, "filepath", "File Path", 0, "", "path of the file to load.");
+ parm= RNA_def_string_file_path(func, "filepath", "File Path", 0, "", "path of the file to load.");
RNA_def_property_flag(parm, PROP_REQUIRED);
/* return type */
parm= RNA_def_pointer(func, "image", "Image", "", "New image datablock.");
@@ -921,7 +921,7 @@
func= RNA_def_function(srna, "load", "rna_Main_fonts_load");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Load a new font into the main database");
- parm= RNA_def_string(func, "filepath", "File Path", 0, "", "path of the font to load.");
+ parm= RNA_def_string_file_path(func, "filepath", "File Path", 0, "", "path of the font to load.");
RNA_def_property_flag(parm, PROP_REQUIRED);
/* return type */
parm= RNA_def_pointer(func, "vfont", "VectorFont", "", "New font datablock.");
@@ -1081,7 +1081,7 @@
func= RNA_def_function(srna, "load", "rna_Main_texts_load");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Add a new text to the main database from a file");
- parm= RNA_def_string(func, "filepath", "Path", FILE_MAXDIR + FILE_MAXFILE, "", "path for the datablock.");
+ parm= RNA_def_string_file_path(func, "filepath", "Path", FILE_MAXDIR + FILE_MAXFILE, "", "path for the datablock.");
RNA_def_property_flag(parm, PROP_REQUIRED);
/* return type */
parm= RNA_def_pointer(func, "text", "Text", "", "New text datablock.");
Modified: trunk/blender/source/blender/makesrna/intern/rna_scene_api.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_scene_api.c 2011-02-01 02:54:29 UTC (rev 34595)
+++ trunk/blender/source/blender/makesrna/intern/rna_scene_api.c 2011-02-01 04:24:47 UTC (rev 34596)
@@ -101,9 +101,8 @@
func= RNA_def_function(srna, "frame_path", "rna_SceneRender_get_frame_path");
RNA_def_function_ui_description(func, "Return the absolute path to the filename to be written for a given frame.");
RNA_def_int(func, "frame", INT_MIN, INT_MIN, INT_MAX, "", "Frame number to use, if unset the current frame will be used.", MINAFRAME, MAXFRAME);
- parm= RNA_def_string(func, "filepath", "", FILE_MAX, "File Path", "the resulting filepath from the scenes render settings.");
+ parm= RNA_def_string_file_path(func, "filepath", "", FILE_MAX, "File Path", "the resulting filepath from the scenes render settings.");
RNA_def_property_flag(parm, PROP_THICK_WRAP); /* needed for string return value */
- RNA_def_property_subtype(parm, PROP_FILEPATH); /* allow non utf8 */
RNA_def_function_output(func, parm);
}
Modified: trunk/blender/source/blender/python/generic/py_capi_utils.c
===================================================================
--- trunk/blender/source/blender/python/generic/py_capi_utils.c 2011-02-01 02:54:29 UTC (rev 34595)
+++ trunk/blender/source/blender/python/generic/py_capi_utils.c 2011-02-01 04:24:47 UTC (rev 34596)
@@ -228,6 +228,10 @@
* chars since blender doesnt limit this */
return result;
}
+ else if(PyBytes_Check(py_str)) {
+ PyErr_Clear();
+ return PyBytes_AS_STRING(py_str);
+ }
else {
/* mostly copied from fileio.c's, fileio_init */
PyObject *stringobj;
More information about the Bf-blender-cvs
mailing list