Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-10-11 08:36:27 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-10-11 08:36:27 +0400
commit751aa8c7f46ecbfe21553df8d8cbebf0f1839921 (patch)
tree339129fae305f70d2bae18c740f7b03d250aff9f /release/scripts/modules/bpy_extras/io_utils.py
parentfa5275cdfa136dd81a15cd2d37f8dadf77f7bcee (diff)
py api: bpy_extras.io_utils.path_reference() - added library argument so exporters get the paths of linked images right.
Diffstat (limited to 'release/scripts/modules/bpy_extras/io_utils.py')
-rw-r--r--release/scripts/modules/bpy_extras/io_utils.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/release/scripts/modules/bpy_extras/io_utils.py b/release/scripts/modules/bpy_extras/io_utils.py
index 91546e02829..5d28ceaa34c 100644
--- a/release/scripts/modules/bpy_extras/io_utils.py
+++ b/release/scripts/modules/bpy_extras/io_utils.py
@@ -350,6 +350,7 @@ def path_reference(filepath,
mode='AUTO',
copy_subdir="",
copy_set=None,
+ library=None,
):
"""
Return a filepath relative to a destination directory, for use with
@@ -372,12 +373,15 @@ def path_reference(filepath,
:arg copy_set: collect from/to pairs when mode='COPY',
pass to *path_reference_copy* when exportign is done.
:type copy_set: set
+ :arg library: The library this path is relative to.
+ :type library: :class:`bpy.types.Library` or None
:return: the new filepath.
:rtype: string
"""
import os
is_relative = filepath.startswith("//")
- filepath_abs = os.path.normpath(bpy.path.abspath(filepath, base_src))
+ filepath_abs = bpy.path.abspath(filepath, base_src, library)
+ filepath_abs = os.path.normpath(filepath_abs)
if mode in {'ABSOLUTE', 'RELATIVE', 'STRIP'}:
pass
@@ -385,13 +389,12 @@ def path_reference(filepath,
mode = 'RELATIVE' if is_relative else 'ABSOLUTE'
elif mode == 'AUTO':
mode = ('RELATIVE'
- if bpy.path.is_subdir(filepath, base_dst)
+ if bpy.path.is_subdir(filepath_abs, base_dst)
else 'ABSOLUTE')
elif mode == 'COPY':
+ subdir_abs = os.path.normpath(base_dst)
if copy_subdir:
- subdir_abs = os.path.join(os.path.normpath(base_dst), copy_subdir)
- else:
- subdir_abs = os.path.normpath(base_dst)
+ subdir_abs = os.path.join(subdir_abs, copy_subdir)
filepath_cpy = os.path.join(subdir_abs, os.path.basename(filepath))