fix [#27148] *Invalid Path* in all "operator presets" dropdowns
authorCampbell Barton <ideasman42@gmail.com>
Mon, 2 May 2011 17:29:30 +0000 (17:29 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 2 May 2011 17:29:30 +0000 (17:29 +0000)
release/scripts/modules/bpy/utils.py
release/scripts/startup/bl_operators/presets.py
release/scripts/startup/bl_operators/wm.py
release/scripts/startup/bl_ui/properties_data_modifier.py
release/scripts/startup/bl_ui/properties_texture.py
release/scripts/startup/bl_ui/space_image.py

index eee98bdca37229b0788851524b6fcd35347376f4..96967a8e4be3f010b1afb019148710fe37fd6a38 100644 (file)
@@ -226,21 +226,35 @@ def user_script_path():
         return None
 
 
-def script_paths(subdir=None, user=True):
+def script_paths(subdir=None, user_pref=True, all=False):
     """
-    Returns a list of valid script paths from the home directory and user preferences.
+    Returns a list of valid script paths.
 
-    Accepts any number of string arguments which are joined to make a path.
+    :arg subdir: Optional subdir.
+    :type subdir: string
+    :arg user_pref: Include the user preference script path.
+    :type user_pref: bool
+    :arg all: Include local, user and system paths rather just the paths blender uses.
+    :type all: bool
+    :return: script paths.
+    :rtype: list
     """
     scripts = list(_scripts)
 
     # add user scripts dir
-    if user:
+    if user_pref:
         user_script_path = _bpy.context.user_preferences.filepaths.script_directory
     else:
         user_script_path = None
 
-    for path in _bpy_script_paths() + (user_script_path, ):
+    if all:
+        # all possible paths
+        base_paths = tuple(_os.path.join(resource_path(res), "scripts") for res in ('LOCAL', 'USER', 'SYSTEM'))
+    else:
+        # only paths blender uses
+        base_paths = _bpy_script_paths()
+
+    for path in base_paths + (user_script_path, ):
         if path:
             path = _os.path.normpath(path)
             if path not in scripts and _os.path.isdir(path):
@@ -266,7 +280,7 @@ def preset_paths(subdir):
     Returns a list of paths for a specific preset.
     """
     dirs = []
-    for path in script_paths("presets"):
+    for path in script_paths("presets", all=True):
         directory = _os.path.join(path, subdir)
         if _os.path.isdir(directory):
             dirs.append(directory)
index aa6a11407af0a37d87ee8099210a21fa755a2add..493c51ad2379ae2f170da9f399adc82ab0cc383f 100644 (file)
@@ -48,11 +48,11 @@ class AddPresetBase():
         preset_menu_class = getattr(bpy.types, self.preset_menu)
 
         if not self.remove_active:
-
-            if not self.name:
+            name = self.name.strip()
+            if not name:
                 return {'FINISHED'}
 
-            filename = self.as_filename(self.name)
+            filename = self.as_filename(name)
 
             target_path = bpy.utils.user_resource('SCRIPTS', os.path.join("presets", self.preset_subdir), create=True)
 
@@ -118,7 +118,7 @@ class AddPresetBase():
         return {'FINISHED'}
 
     def check(self, context):
-        self.name = self.as_filename(self.name)
+        self.name = self.as_filename(self.name.strip())
 
     def invoke(self, context, event):
         if not self.remove_active:
@@ -327,7 +327,7 @@ class AddPresetOperator(AddPresetBase, bpy.types.Operator):
         ret = []
         for prop_id, prop in operator_rna.properties.items():
             if (not prop.is_hidden) and prop_id not in properties_blacklist:
-                    ret.append("op.%s" % prop_id)
+                ret.append("op.%s" % prop_id)
 
         return ret
 
index d02b2bfbdde1aee001f5e9611b8bf69d9a5e5ff0..53c8d56229717ee43a6cd3b263ad3a4a54e61297 100644 (file)
@@ -837,6 +837,7 @@ class WM_OT_properties_add(bpy.types.Operator):
         item[property] = 1.0
         return {'FINISHED'}
 
+
 class WM_OT_properties_context_change(bpy.types.Operator):
     "Change the context tab in a Properties Window"
     bl_idname = "wm.properties_context_change"
@@ -846,7 +847,6 @@ class WM_OT_properties_context_change(bpy.types.Operator):
 
     def execute(self, context):
         context.space_data.context = (self.context)
-               
         return {'FINISHED'}
 
 
index 817ad1d3a76ee434e08605af6d2a1aba5c5c189d..1fa79a88f439bc9f6c33346ae5d8869d85a61bda 100644 (file)
@@ -581,7 +581,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, bpy.types.Panel):
         col.prop(md, "use_even_offset")
         col.prop(md, "use_quality_normals")
         col.prop(md, "use_rim")
-        
+
         sub = col.column()
         sub.label()
         row = sub.split(align=True, percentage=0.4)
index be46eb5dca6c1a876500b55a16cfcf26fa7364c9..01890bc3c99d0de455187eeda020ff178d25af44 100644 (file)
@@ -723,9 +723,9 @@ class TEXTURE_PT_pointdensity(TextureButtonsPanel, bpy.types.Panel):
             col.prop(pd, "falloff_soft")
         if pd.falloff == "PARTICLE_VELOCITY":
             col.prop(pd, "falloff_speed_scale")
-        
+
         col.prop(pd, "use_falloff_curve")
-        
+
         if pd.use_falloff_curve:
             col = layout.column()
             col.label(text="Falloff Curve")
index 0bdc239c408703dcfecfbde50265babd5ad456b5..77583b8082476aa173f13d4a74aceb5c28c21e0c 100644 (file)
@@ -370,7 +370,7 @@ class IMAGE_HT_header(bpy.types.Header):
             layout.prop(toolsettings, "use_uv_select_sync", text="")
 
             if toolsettings.use_uv_select_sync:
-               layout.template_edit_mode_selection()
+                layout.template_edit_mode_selection()
             else:
                 layout.prop(toolsettings, "uv_select_mode", text="", expand=True)
                 layout.prop(uvedit, "sticky_select_mode", text="", icon_only=True)