[Bf-blender-cvs] [2e2fd12a550] master: Cleanup: comments for is_path_builtin

Campbell Barton noreply at git.blender.org
Thu Oct 31 08:17:21 CET 2019


Commit: 2e2fd12a55038b5e520720efe76bd0a1c2059fc1
Author: Campbell Barton
Date:   Thu Oct 31 18:01:58 2019 +1100
Branches: master
https://developer.blender.org/rB2e2fd12a55038b5e520720efe76bd0a1c2059fc1

Cleanup: comments for is_path_builtin

Also reduce scope of import.

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

M	release/scripts/modules/bpy/utils/__init__.py
M	release/scripts/startup/bl_operators/presets.py
M	release/scripts/startup/bl_ui/space_filebrowser.py

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

diff --git a/release/scripts/modules/bpy/utils/__init__.py b/release/scripts/modules/bpy/utils/__init__.py
index 879275619ce..74cc54bb544 100644
--- a/release/scripts/modules/bpy/utils/__init__.py
+++ b/release/scripts/modules/bpy/utils/__init__.py
@@ -456,12 +456,19 @@ def preset_paths(subdir):
 
     return dirs
 
+
 def is_path_builtin(path):
     """
-    Returns True if the path in question in one of the built in paths used by blender.
+    Returns True if the path is one of the built-in paths used by Blender.
 
-    :arg path: Path you want to check if it is in the built in settings directory
+    :arg path: Path you want to check if it is in the built-in settings directory
+    :type path: str
+    :rtype: bool
     """
+    # Note that this function is is not optimized for speed,
+    # it's intended to be used to check if it's OK to remove presets.
+    #
+    # If this is used in a draw-loop for example, we could cache some of the values.
     search_path = _os.path.abspath(path)
     user_path = resource_path('USER')
 
@@ -469,15 +476,19 @@ def is_path_builtin(path):
         parent_path = resource_path(res)
         if not parent_path or parent_path == user_path:
             # Make sure that the current path is not empty string and that it is
-            # not the same as the user config path. IE "~/.config/blender" on linux
+            # not the same as the user config path. IE "~/.config/blender" on Linux
             # This can happen on portable installs.
             continue
 
-        if _os.path.samefile(_os.path.commonpath([parent_path]), _os.path.commonpath([parent_path, path])):
+        if _os.path.samefile(
+                _os.path.commonpath([parent_path]),
+                _os.path.commonpath([parent_path, path])
+        ):
             return True
 
     return False
 
+
 def smpte_from_seconds(time, fps=None, fps_base=None):
     """
     Returns an SMPTE formatted string from the *time*:
diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py
index 235f92bd360..deb33f77050 100644
--- a/release/scripts/startup/bl_operators/presets.py
+++ b/release/scripts/startup/bl_operators/presets.py
@@ -29,8 +29,6 @@ from bpy.props import (
     StringProperty,
 )
 
-from bpy.utils import is_path_builtin
-
 # For preset popover menu
 WindowManager.preset_name = StringProperty(
     name="Preset Name",
@@ -86,6 +84,7 @@ class AddPresetBase:
 
     def execute(self, context):
         import os
+        from bpy.utils import is_path_builtin
 
         if hasattr(self, "pre_cb"):
             self.pre_cb(context)
diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py
index 37271f2e242..958052c8f25 100644
--- a/release/scripts/startup/bl_ui/space_filebrowser.py
+++ b/release/scripts/startup/bl_ui/space_filebrowser.py
@@ -432,7 +432,7 @@ class FILEBROWSER_MT_view(Menu):
 class FILEBROWSER_MT_select(Menu):
     bl_label = "Select"
 
-    def draw(self, context):
+    def draw(self, _context):
         layout = self.layout
 
         layout.operator("file.select_all", text="All").action = 'SELECT'



More information about the Bf-blender-cvs mailing list