diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-10-31 10:01:58 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-10-31 10:01:58 +0300 |
commit | 2e2fd12a55038b5e520720efe76bd0a1c2059fc1 (patch) | |
tree | 8b7eb838e6795062c4dbfe9cd6514db0ad957828 /release/scripts/modules | |
parent | 3252ef4aca7a112fa5c2c00567c455bd27c9d963 (diff) |
Cleanup: comments for is_path_builtin
Also reduce scope of import.
Diffstat (limited to 'release/scripts/modules')
-rw-r--r-- | release/scripts/modules/bpy/utils/__init__.py | 19 |
1 files changed, 15 insertions, 4 deletions
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*: |