diff options
-rw-r--r-- | release/scripts/modules/addon_utils.py | 70 | ||||
-rw-r--r-- | release/scripts/startup/bl_operators/screen_play_rendered_anim.py | 2 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_text.py | 4 |
3 files changed, 46 insertions, 30 deletions
diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py index 1814c87deda..86185b96e9d 100644 --- a/release/scripts/modules/addon_utils.py +++ b/release/scripts/modules/addon_utils.py @@ -78,7 +78,7 @@ def modules_refresh(module_cache=addons_fake_modules): try: file_mod = open(mod_path, "r", encoding='UTF-8') except OSError as ex: - print("Error opening file %r: %s" % (mod_path, ex)) + print("Error opening file:", mod_path, ex) return None with file_mod: @@ -116,7 +116,7 @@ def modules_refresh(module_cache=addons_fake_modules): try: ast_data = ast.parse(data, filename=mod_path) except: - print("Syntax error 'ast.parse' can't read %r" % mod_path) + print("Syntax error 'ast.parse' can't read:", repr(mod_path)) import traceback traceback.print_exc() ast_data = None @@ -138,7 +138,7 @@ def modules_refresh(module_cache=addons_fake_modules): mod.__file__ = mod_path mod.__time__ = os.path.getmtime(mod_path) except: - print("AST error parsing bl_info for %s" % mod_name) + print("AST error parsing bl_info for:", mod_name) import traceback traceback.print_exc() raise @@ -148,8 +148,11 @@ def modules_refresh(module_cache=addons_fake_modules): return mod else: - print("fake_module: addon missing 'bl_info' " - "gives bad performance!: %r" % mod_path) + print( + "fake_module: addon missing 'bl_info' " + "gives bad performance!:", + repr(mod_path), + ) return None modules_stale = set(module_cache.keys()) @@ -167,17 +170,21 @@ def modules_refresh(module_cache=addons_fake_modules): mod = module_cache.get(mod_name) if mod: if mod.__file__ != mod_path: - print("multiple addons with the same name:\n %r\n %r" % - (mod.__file__, mod_path)) + print( + "multiple addons with the same name:\n" + " " f"{mod.__file__!r}" "\n" + " " f"{mod_path!r}" + ) error_duplicates.append((mod.bl_info["name"], mod.__file__, mod_path)) elif mod.__time__ != os.path.getmtime(mod_path): - print("reloading addon:", - mod_name, - mod.__time__, - os.path.getmtime(mod_path), - mod_path, - ) + print( + "reloading addon:", + mod_name, + mod.__time__, + os.path.getmtime(mod_path), + repr(mod_path), + ) del module_cache[mod_name] mod = None @@ -233,10 +240,12 @@ def check(module_name): ) if loaded_state is Ellipsis: - print("Warning: addon-module %r found module " - "but without __addon_enabled__ field, " - "possible name collision from file: %r" % - (module_name, getattr(mod, "__file__", "<unknown>"))) + print( + "Warning: addon-module " f"{module_name:s}" " found module " + "but without '__addon_enabled__' field, " + "possible name collision from file:", + repr(getattr(mod, "__file__", "<unknown>")), + ) loaded_state = False @@ -303,8 +312,10 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non try: mod.unregister() except Exception as ex: - print("Exception in module unregister(): %r" % - getattr(mod, "__file__", module_name)) + print( + "Exception in module unregister():", + repr(getattr(mod, "__file__", module_name)), + ) handle_error(ex) return None @@ -313,7 +324,7 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non mtime_new = os.path.getmtime(mod.__file__) if mtime_orig != mtime_new: import importlib - print("module changed on disk:", mod.__file__, "reloading...") + print("module changed on disk:", repr(mod.__file__), "reloading...") try: importlib.reload(mod) @@ -343,7 +354,7 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non except Exception as ex: # if the addon doesn't exist, dont print full traceback if type(ex) is ImportError and ex.name == module_name: - print("addon not found: %r" % module_name) + print("addon not found:", repr(module_name)) else: handle_error(ex) @@ -387,8 +398,10 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non try: mod.register() except Exception as ex: - print("Exception in module register(): %r" % - getattr(mod, "__file__", module_name)) + print( + "Exception in module register():", + getattr(mod, "__file__", module_name), + ) handle_error(ex) del sys.modules[module_name] if default_set: @@ -438,12 +451,15 @@ def disable(module_name, *, default_set=False, handle_error=None): try: mod.unregister() except Exception as ex: - print("Exception in module unregister(): %r" % - getattr(mod, "__file__", module_name)) + mod_path = getattr(mod, "__file__", module_name) + print("Exception in module unregister():", repr(mod_path)) + del mod_path handle_error(ex) else: - print("addon_utils.disable: %s not %s." % - (module_name, "disabled" if mod is None else "loaded")) + print( + "addon_utils.disable: " f"{module_name:s}" " not", + ("disabled" if mod is None else "loaded") + ) # could be in more than once, unlikely but better do this just in case. if default_set: diff --git a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py index 46cf07be0f5..27c8487eaa9 100644 --- a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py +++ b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py @@ -149,7 +149,7 @@ class PlayRenderedAnim(Operator): opts = [file, f"{scene.frame_start:d}-{scene.frame_end:d}"] cmd.extend(opts) elif preset == 'RV': - opts = ["-fps", str(rd.fps), "-play", f"[ {file} ]"] + opts = ["-fps", str(rd.fps), "-play", f"[ {file:s} ]"] cmd.extend(opts) elif preset == 'MPLAYER': opts = [] diff --git a/release/scripts/startup/bl_ui/space_text.py b/release/scripts/startup/bl_ui/space_text.py index 95124d2be83..8e370326d8c 100644 --- a/release/scripts/startup/bl_ui/space_text.py +++ b/release/scripts/startup/bl_ui/space_text.py @@ -60,12 +60,12 @@ class TEXT_HT_header(Header): if text.filepath: if text.is_dirty: row.label( - iface_(f"File: *{text.filepath} (unsaved)"), + iface_(f"File: *{text.filepath:s} (unsaved)"), translate=False, ) else: row.label( - iface_(f"File: {text.filepath}"), + iface_(f"File: {text.filepath:s}"), translate=False, ) else: |