[Bf-blender-cvs] [3ec6ecb3e5] app-templates: Use much more specific checks for template directories

Campbell Barton noreply at git.blender.org
Fri Mar 24 09:15:24 CET 2017


Commit: 3ec6ecb3e5530e8d008d7def3647c8a69ff2eed0
Author: Campbell Barton
Date:   Fri Mar 24 19:15:21 2017 +1100
Branches: app-templates
https://developer.blender.org/rB3ec6ecb3e5530e8d008d7def3647c8a69ff2eed0

Use much more specific checks for template directories

===================================================================

M	release/scripts/modules/bpy/utils/__init__.py

===================================================================

diff --git a/release/scripts/modules/bpy/utils/__init__.py b/release/scripts/modules/bpy/utils/__init__.py
index cefa505d8a..725adcc6ca 100644
--- a/release/scripts/modules/bpy/utils/__init__.py
+++ b/release/scripts/modules/bpy/utils/__init__.py
@@ -370,17 +370,32 @@ def app_template_paths(subdir=None):
     :arg subdir: Optional subdir.
     :type subdir: string
     :return: app template paths.
-    :rtype: list
+    :rtype: generator
     """
-    import os
-    scripts = []
-    for sub in ("bl_app_templates_user", "bl_app_templates_system"):
-        if subdir is not None:
-            sub = os.path.join("startup", sub, subdir)
-        else:
-            sub = os.path.join("startup", sub)
-        scripts.extend(script_paths(subdir=sub, user_pref=False, check_all=True))
-    return scripts
+
+    # note: LOCAL, USER, SYSTEM order matches script resolution order.
+    subdir_tuple = (subdir,) if subdir is not None else ()
+
+    path = _os.path.join(*(
+        resource_path('LOCAL'), "scripts", "startup",
+        "bl_app_templates_user", *subdir_tuple))
+    print(path)
+    if _os.path.isdir(path):
+        yield path
+    else:
+        path = _os.path.join(*(
+            resource_path('USER'), "scripts", "startup",
+            "bl_app_templates_user", *subdir_tuple))
+        print(path)
+        if _os.path.isdir(path):
+            yield path
+
+    path = _os.path.join(*(
+        resource_path('SYSTEM'), "scripts", "startup",
+        "bl_app_templates_system", *subdir_tuple))
+    print(path)
+    if _os.path.isdir(path):
+        yield path
 
 
 def preset_paths(subdir):




More information about the Bf-blender-cvs mailing list