[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25672] trunk/blender: new python submodule.

Campbell Barton ideasman42 at gmail.com
Sun Jan 3 00:14:01 CET 2010


Revision: 25672
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25672
Author:   campbellbarton
Date:     2010-01-03 00:14:01 +0100 (Sun, 03 Jan 2010)

Log Message:
-----------
new python submodule. eg.
from bpy.app import binary_path, version, version_string, home

can add constant variables from blender here as needed (maybe functions too... bpy.app.memory_usage() ?)

Modified Paths:
--------------
    trunk/blender/release/scripts/io/export_fbx.py
    trunk/blender/release/scripts/io/export_obj.py
    trunk/blender/release/scripts/io/export_ply.py
    trunk/blender/release/scripts/modules/bpy/__init__.py
    trunk/blender/release/scripts/ui/space_info.py
    trunk/blender/source/blender/python/intern/bpy_interface.c

Added Paths:
-----------
    trunk/blender/release/scripts/modules/bpy/app.py

Modified: trunk/blender/release/scripts/io/export_fbx.py
===================================================================
--- trunk/blender/release/scripts/io/export_fbx.py	2010-01-02 22:47:56 UTC (rev 25671)
+++ trunk/blender/release/scripts/io/export_fbx.py	2010-01-02 23:14:01 UTC (rev 25672)
@@ -651,7 +651,7 @@
 }''' % (curtime))
 
     file.write('\nCreationTime: "%.4i-%.2i-%.2i %.2i:%.2i:%.2i:000"' % curtime)
-    file.write('\nCreator: "Blender3D version %s"' % bpy.version_string)
+    file.write('\nCreator: "Blender3D version %s"' % bpy.app.version_string)
 
 
     pose_items = [] # list of (fbxName, matrix) to write pose data for, easier to collect allong the way

Modified: trunk/blender/release/scripts/io/export_obj.py
===================================================================
--- trunk/blender/release/scripts/io/export_obj.py	2010-01-02 22:47:56 UTC (rev 25671)
+++ trunk/blender/release/scripts/io/export_obj.py	2010-01-02 23:14:01 UTC (rev 25672)
@@ -361,7 +361,7 @@
     file = open(filename, "w")
 
     # Write Header
-    file.write('# Blender3D v%s OBJ File: %s\n' % (bpy.version_string, bpy.data.filename.split('/')[-1].split('\\')[-1] ))
+    file.write('# Blender3D v%s OBJ File: %s\n' % (bpy.app.version_string, bpy.data.filename.split('/')[-1].split('\\')[-1] ))
     file.write('# www.blender3d.org\n')
 
     # Tell the obj file what material file to use.

Modified: trunk/blender/release/scripts/io/export_ply.py
===================================================================
--- trunk/blender/release/scripts/io/export_ply.py	2010-01-02 22:47:56 UTC (rev 25671)
+++ trunk/blender/release/scripts/io/export_ply.py	2010-01-02 23:14:01 UTC (rev 25672)
@@ -205,7 +205,7 @@
 
     file.write('ply\n')
     file.write('format ascii 1.0\n')
-    file.write('comment Created by Blender3D %s - www.blender.org, source file: %s\n' % (bpy.version_string, bpy.data.filename.split('/')[-1].split('\\')[-1]))
+    file.write('comment Created by Blender3D %s - www.blender.org, source file: %s\n' % (bpy.app.version_string, bpy.data.filename.split('/')[-1].split('\\')[-1]))
 
     file.write('element vertex %d\n' % len(ply_verts))
 

Modified: trunk/blender/release/scripts/modules/bpy/__init__.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy/__init__.py	2010-01-02 22:47:56 UTC (rev 25671)
+++ trunk/blender/release/scripts/modules/bpy/__init__.py	2010-01-02 23:14:01 UTC (rev 25672)
@@ -27,6 +27,7 @@
 
 # python modules
 from bpy import utils
+from bpy import app
 
 from bpy import ops as _ops_module
 
@@ -100,9 +101,4 @@
         load_scripts()
 
 
-# constants
-version = _bpy._VERSION
-version_string = _bpy._VERSION_STR
-home = _bpy._HOME
-
 _main()

Added: trunk/blender/release/scripts/modules/bpy/app.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy/app.py	                        (rev 0)
+++ trunk/blender/release/scripts/modules/bpy/app.py	2010-01-02 23:14:01 UTC (rev 25672)
@@ -0,0 +1,26 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+
+# constants
+import _bpy
+version = _bpy._VERSION
+version_string = _bpy._VERSION_STR
+home = _bpy._HOME
+binary_path = _bpy._BINPATH


Property changes on: trunk/blender/release/scripts/modules/bpy/app.py
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: trunk/blender/release/scripts/ui/space_info.py
===================================================================
--- trunk/blender/release/scripts/ui/space_info.py	2010-01-02 22:47:56 UTC (rev 25671)
+++ trunk/blender/release/scripts/ui/space_info.py	2010-01-02 23:14:01 UTC (rev 25672)
@@ -121,7 +121,7 @@
         import os
         layout = self.layout
         layout.operator_context = 'EXEC_AREA'
-        file = open(os.path.join(bpy.home, ".Blog"), "rU")
+        file = open(os.path.join(bpy.app.home, ".Blog"), "rU")
         for line in file:
             line = line.rstrip()
             layout.operator("wm.open_mainfile", text=line, icon='FILE_BLEND').path = line

Modified: trunk/blender/source/blender/python/intern/bpy_interface.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_interface.c	2010-01-02 22:47:56 UTC (rev 25671)
+++ trunk/blender/source/blender/python/intern/bpy_interface.c	2010-01-02 23:14:01 UTC (rev 25672)
@@ -223,12 +223,15 @@
 
 	/* blender info that wont change at runtime, add into _bpy */
 	{
+		extern char bprogname[]; /* argv[0] from creator.c */
+
 		PyObject *mod_dict= PyModule_GetDict(mod);
 		char tmpstr[256];
 		PyModule_AddStringConstant(mod, "_HOME",  BLI_gethome());
 		PyDict_SetItemString(mod_dict, "_VERSION", Py_BuildValue("(iii)", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION));
 		sprintf(tmpstr, "%d.%02d (sub %d)", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION);
 		PyModule_AddStringConstant(mod, "_VERSION_STR",  tmpstr);
+		PyModule_AddStringConstant(mod, "_BINPATH",  bprogname);
 	}
 
 	/* add our own modules dir, this is a python package */





More information about the Bf-blender-cvs mailing list