diff options
Diffstat (limited to 'release/scripts/modules/bpy/path.py')
-rw-r--r-- | release/scripts/modules/bpy/path.py | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/release/scripts/modules/bpy/path.py b/release/scripts/modules/bpy/path.py index 98a3c81d65a..7b54af944ad 100644 --- a/release/scripts/modules/bpy/path.py +++ b/release/scripts/modules/bpy/path.py @@ -118,6 +118,14 @@ def clean_name(name, replace="_"): return name +def _clean_utf8(name): + name = _os.path.splitext(basename(name))[0] + if type(name) == bytes: + return name.decode("utf8", "replace") + else: + return name.encode("utf8", "replace").decode("utf8") + + def display_name(name): """ Creates a display string from name to be used menus and the user interface. @@ -126,17 +134,18 @@ def display_name(name): filenames and module names. """ - name_base = _os.path.splitext(name)[0] + name = _os.path.splitext(name)[0] # string replacements - name_base = name_base.replace("_colon_", ":") + name = name.replace("_colon_", ":") - name_base = name_base.replace("_", " ") + name = name.replace("_", " ") - if name_base.islower(): - return name_base.lower().title() - else: - return name_base + if name.islower(): + name = name.lower().title() + + name = _clean_utf8(name) + return name def display_name_from_filepath(name): @@ -144,8 +153,10 @@ def display_name_from_filepath(name): Returns the path stripped of directory and extension, ensured to be utf8 compatible. """ + name = _os.path.splitext(basename(name))[0] - return name.encode("utf8", "replace").decode("utf8") + name = _clean_utf8(name) + return name def resolve_ncase(path): |