diff options
Diffstat (limited to 'release/scripts')
-rw-r--r-- | release/scripts/modules/bpy/path.py | 30 | ||||
-rw-r--r-- | release/scripts/startup/bl_operators/presets.py | 16 |
2 files changed, 26 insertions, 20 deletions
diff --git a/release/scripts/modules/bpy/path.py b/release/scripts/modules/bpy/path.py index 9a90797bf28..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,11 +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] - if type(name) == bytes: - return name.decode("utf8", "replace") - else: - return name.encode("utf8", "replace").decode("utf8") + name = _clean_utf8(name) + return name def resolve_ncase(path): diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py index 1a17cd9f000..abd940e06f9 100644 --- a/release/scripts/startup/bl_operators/presets.py +++ b/release/scripts/startup/bl_operators/presets.py @@ -20,7 +20,7 @@ import bpy from bpy.types import Menu, Operator - +from bpy.props import StringProperty, BoolProperty class AddPresetBase(): '''Base preset class, only for subclassing @@ -31,13 +31,13 @@ class AddPresetBase(): # bl_label = "Add a Python Preset" bl_options = {'REGISTER'} # only because invoke_props_popup requires. - name = bpy.props.StringProperty( + name = StringProperty( name="Name", description="Name of the preset, used to make the path name", maxlen=64, options={'SKIP_SAVE'}, ) - remove_active = bpy.props.BoolProperty( + remove_active = BoolProperty( default=False, options={'HIDDEN', 'SKIP_SAVE'}, ) @@ -166,12 +166,10 @@ class ExecutePreset(Operator): bl_idname = "script.execute_preset" bl_label = "Execute a Python Preset" - filepath = bpy.props.StringProperty( - name="Path", - description="Path of the Python file to execute", - maxlen=512, + filepath = StringProperty( + subtype='FILE_PATH', ) - menu_idname = bpy.props.StringProperty( + menu_idname = StringProperty( name="Menu ID Name", description="ID name of the menu this was called from", ) @@ -456,7 +454,7 @@ class AddPresetOperator(AddPresetBase, Operator): bl_label = "Operator Preset" preset_menu = "WM_MT_operator_presets" - operator = bpy.props.StringProperty( + operator = StringProperty( name="Operator", maxlen=64, options={'HIDDEN'}, |