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-08-15 08:58:19 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-08-15 08:58:19 +0400
commit551e8bc72c1a0be6fbc32153952036e3fc83560f (patch)
tree2e186fb09ed880546b5ed9b9435c5240e4943d6f /release/scripts/modules/bpy_extras/io_utils.py
parente4f2234fffff40afa7f74dc33b5e0f8ad1a7d78f (diff)
py api - optional sep argument for bpy_extra.io_utils.unique_name() since for some formats '.' is an invalid char.
Diffstat (limited to 'release/scripts/modules/bpy_extras/io_utils.py')
-rw-r--r--release/scripts/modules/bpy_extras/io_utils.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/release/scripts/modules/bpy_extras/io_utils.py b/release/scripts/modules/bpy_extras/io_utils.py
index bb4e95c051f..6271c1f77b5 100644
--- a/release/scripts/modules/bpy_extras/io_utils.py
+++ b/release/scripts/modules/bpy_extras/io_utils.py
@@ -439,7 +439,7 @@ def path_reference_copy(copy_set, report=print):
shutil.copy(file_src, file_dst)
-def unique_name(key, name, name_dict, name_max=-1, clean_func=None):
+def unique_name(key, name, name_dict, name_max=-1, clean_func=None, sep="."):
"""
Helper function for storing unique names which may have special characters
stripped and restricted to a maximum length.
@@ -456,6 +456,9 @@ def unique_name(key, name, name_dict, name_max=-1, clean_func=None):
:type name_dict: dict
:arg clean_func: Function to call on *name* before creating a unique value.
:type clean_func: function
+ :arg sep: Separator to use when between the name and a number when a
+ duplicate name is found.
+ :type sep: string
"""
name_new = name_dict.get(key)
if name_new is None:
@@ -466,14 +469,15 @@ def unique_name(key, name, name_dict, name_max=-1, clean_func=None):
if name_max == -1:
while name_new in name_dict_values:
- name_new = "%s.%03d" % (name_new_orig, count)
+ name_new = "%s%s%03d" % (name_new_orig, sep, count)
count += 1
else:
name_new = name_new[:name_max]
while name_new in name_dict_values:
count_str = "%03d" % count
- name_new = "%.*s.%s" % (name_max - (len(count_str) + 1),
+ name_new = "%.*s%s%s" % (name_max - (len(count_str) + 1),
name_new_orig,
+ sep,
count_str,
)
count += 1