Tests: split off render report test code from Cycles tests.
[blender.git] / tests / python / batch_import.py
index 8fc679a7c154deccd2ef61797f021da15dc90f09..a6e2469349bdccdc4ca3254b35a2ac945ea552a3 100644 (file)
@@ -48,29 +48,17 @@ import os
 import sys
 
 
-def clear_scene():
-    import bpy
-    unique_obs = set()
-    for scene in bpy.data.scenes:
-        for obj in scene.objects[:]:
-            scene.objects.unlink(obj)
-            unique_obs.add(obj)
-
-    # remove obdata, for now only worry about the startup scene
-    for bpy_data_iter in (bpy.data.objects, bpy.data.meshes, bpy.data.lamps, bpy.data.cameras):
-        for id_data in bpy_data_iter:
-            bpy_data_iter.remove(id_data)
-
-
-def batch_import(operator="",
-                 path="",
-                 save_path="",
-                 match="",
-                 start=0,
-                 end=sys.maxsize,
-                 ):
+def batch_import(
+    operator="",
+    path="",
+    save_path="",
+    match="",
+    start=0,
+    end=sys.maxsize,
+):
     import addon_utils
     _reset_all = addon_utils.reset_all  # XXX, hack
+    _disable_all = addon_utils.disable_all  # XXX, hack
 
     import fnmatch
 
@@ -84,10 +72,8 @@ def batch_import(operator="",
 
     def file_generator(path):
         for dirpath, dirnames, filenames in os.walk(path):
-
-            # skip '.svn'
-            if dirpath.startswith("."):
-                continue
+            # skip '.git'
+            dirnames[:] = [d for d in dirnames if not d.startswith(".")]
 
             for filename in filenames:
                 if pattern_match(filename):
@@ -116,11 +102,12 @@ def batch_import(operator="",
 
         # hack so loading the new file doesn't undo our loaded addons
         addon_utils.reset_all = lambda: None  # XXX, hack
+        addon_utils.disable_all = lambda: None  # XXX, hack
 
-        bpy.ops.wm.read_factory_settings()
+        bpy.ops.wm.read_factory_settings(use_empty=True)
 
         addon_utils.reset_all = _reset_all  # XXX, hack
-        clear_scene()
+        addon_utils.disable_all = _disable_all  # XXX, hack
 
         result = op(filepath=f)