[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26365] trunk/blender/release/scripts: move bpy.load_scripts --> bpy.utils.load_scripts

Campbell Barton ideasman42 at gmail.com
Thu Jan 28 12:48:07 CET 2010


Revision: 26365
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26365
Author:   campbellbarton
Date:     2010-01-28 12:48:06 +0100 (Thu, 28 Jan 2010)

Log Message:
-----------
move bpy.load_scripts --> bpy.utils.load_scripts
added sequencer strip length display in seconds

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/bpy/__init__.py
    trunk/blender/release/scripts/modules/bpy/utils.py
    trunk/blender/release/scripts/ui/space_sequencer.py

Modified: trunk/blender/release/scripts/modules/bpy/__init__.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy/__init__.py	2010-01-28 11:40:38 UTC (rev 26364)
+++ trunk/blender/release/scripts/modules/bpy/__init__.py	2010-01-28 11:48:06 UTC (rev 26365)
@@ -36,76 +36,8 @@
 
 import sys as _sys
 
-def load_scripts(reload_scripts=False):
-    import os
-    import traceback
-    import time
 
 
-    t_main = time.time()
-
-    loaded_modules = set()
-
-    def test_import(module_name):
-        if module_name in loaded_modules:
-            return None
-        if "." in module_name:
-            print("Ignoring '%s', can't import files containing multiple periods." % module_name)
-            return None
-
-        try:
-            t = time.time()
-            ret = __import__(module_name)
-            if app.debug:
-                print("time %s %.4f" % (module_name, time.time() - t))
-            return ret
-        except:
-            traceback.print_exc()
-            return None
-
-    def test_reload(module):
-        try:
-            reload(module)
-        except:
-            traceback.print_exc()
-
-    if reload_scripts:
-        # reload modules that may not be directly included
-        for type_class_name in dir(types):
-            type_class = getattr(types, type_class_name)
-            module_name = getattr(type_class, "__module__", "")
-
-            if module_name and module_name != "bpy.types": # hard coded for C types
-               loaded_modules.add(module_name)
-
-        for module_name in loaded_modules:
-            print("Reloading:", module_name)
-            test_reload(_sys.modules[module_name])
-
-    for base_path in utils.script_paths():
-        for path_subdir in ("ui", "op", "io"):
-            path = os.path.join(base_path, path_subdir)
-            if os.path.isdir(path):
-                if path not in _sys.path: # reloading would add twice
-                    _sys.path.insert(0, path)
-                for f in sorted(os.listdir(path)):
-                    if f.endswith(".py"):
-                        # python module
-                        mod = test_import(f[0:-3])
-                    elif "." not in f:
-                        # python package
-                        mod = test_import(f)
-                    else:
-                        mod = None
-
-                    if reload_scripts and mod:
-                        print("Reloading:", mod)
-                        test_reload(mod)
-
-    if app.debug:
-        print("Time %.4f" % (time.time() - t_main))
-
-
 def _main():
 
     # security issue, dont allow the $CWD in the path.
@@ -119,14 +51,14 @@
     # if "-d" in sys.argv: # Enable this to measure startup speed
     if 0:
         import cProfile
-        cProfile.run('import bpy; bpy.load_scripts()', 'blender.prof')
+        cProfile.run('import bpy; bpy.utils.load_scripts()', 'blender.prof')
 
         import pstats
         p = pstats.Stats('blender.prof')
         p.sort_stats('cumulative').print_stats(100)
 
     else:
-        load_scripts()
+        utils.load_scripts()
 
 
 _main()

Modified: trunk/blender/release/scripts/modules/bpy/utils.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy/utils.py	2010-01-28 11:40:38 UTC (rev 26364)
+++ trunk/blender/release/scripts/modules/bpy/utils.py	2010-01-28 11:48:06 UTC (rev 26365)
@@ -25,8 +25,82 @@
 
 import bpy as _bpy
 import os as _os
+import sys as _sys
 
+def load_scripts(reload_scripts=False, refresh_scripts=False):
+    import traceback
+    import time
 
+    t_main = time.time()
+
+    loaded_modules = set()
+
+    def test_import(module_name):
+        if module_name in loaded_modules:
+            return None
+        if "." in module_name:
+            print("Ignoring '%s', can't import files containing multiple periods." % module_name)
+            return None
+
+        try:
+            t = time.time()
+            ret = __import__(module_name)
+            if _bpy.app.debug:
+                print("time %s %.4f" % (module_name, time.time() - t))
+            return ret
+        except:
+            traceback.print_exc()
+            return None
+
+    def test_reload(module):
+        try:
+            reload(module)
+        except:
+            traceback.print_exc()
+
+    if reload_scripts:
+        # reload modules that may not be directly included
+        for type_class_name in dir(types):
+            type_class = getattr(types, type_class_name)
+            module_name = getattr(type_class, "__module__", "")
+
+            if module_name and module_name != "bpy.types": # hard coded for C types
+               loaded_modules.add(module_name)
+
+        for module_name in loaded_modules:
+            print("Reloading:", module_name)
+            test_reload(_sys.modules[module_name])
+
+    for base_path in script_paths():
+        for path_subdir in ("ui", "op", "io"):
+            path = _os.path.join(base_path, path_subdir)
+            if _os.path.isdir(path):
+
+                # needed to load scripts after the users script path changes
+                # we should also support a full reload but since this is now unstable it can be postponed.
+                if refresh_scripts and path in _sys.path:
+                    continue
+
+                if path not in _sys.path: # reloading would add twice
+                    _sys.path.insert(0, path)
+                for f in sorted(_os.listdir(path)):
+                    if f.endswith(".py"):
+                        # python module
+                        mod = test_import(f[0:-3])
+                    elif "." not in f:
+                        # python package
+                        mod = test_import(f)
+                    else:
+                        mod = None
+
+                    if reload_scripts and mod:
+                        print("Reloading:", mod)
+                        test_reload(mod)
+
+    if _bpy.app.debug:
+        print("Time %.4f" % (time.time() - t_main))
+
+
 def expandpath(path):
     if path.startswith("//"):
         return _os.path.join(_os.path.dirname(_bpy.data.filename), path[2:])

Modified: trunk/blender/release/scripts/ui/space_sequencer.py
===================================================================
--- trunk/blender/release/scripts/ui/space_sequencer.py	2010-01-28 11:40:38 UTC (rev 26364)
+++ trunk/blender/release/scripts/ui/space_sequencer.py	2010-01-28 11:48:06 UTC (rev 26365)
@@ -310,7 +310,7 @@
 
     def draw(self, context):
         layout = self.layout
-
+        render_data = context.scene.render_data
         strip = act_strip(context)
 
         split = layout.split(percentage=0.3)
@@ -344,7 +344,9 @@
         col.enabled = not strip.lock
         col.prop(strip, "channel")
         col.prop(strip, "start_frame")
-        col.prop(strip, "length")
+        subrow = col.split(percentage=0.66)
+        subrow.prop(strip, "length")
+        subrow.label(text="%.2f sec" % (strip.length / (render_data.fps / render_data.fps_base)))
 
         col = layout.column(align=True)
         col.label(text="Offset:")





More information about the Bf-blender-cvs mailing list