diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-11-15 10:42:23 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-11-15 10:46:00 +0300 |
commit | 5ec1d709e7717537b9f60e4b9ea997c56f6c5c15 (patch) | |
tree | c87a6bbe5d8ab37eeac0ea4304c5fb5ef9e8669b /release/scripts/startup/bl_operators/presets.py | |
parent | 49cd13768f4435ca4d109768e5a6a96db21404ee (diff) |
WM: use Python bytecode cache to run presets
Key-maps can be very large, avoid parsing on every startup.
Diffstat (limited to 'release/scripts/startup/bl_operators/presets.py')
-rw-r--r-- | release/scripts/startup/bl_operators/presets.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py index 5ff8f6f591c..9b83ee92ab4 100644 --- a/release/scripts/startup/bl_operators/presets.py +++ b/release/scripts/startup/bl_operators/presets.py @@ -245,9 +245,14 @@ class ExecutePreset(Operator): if hasattr(preset_class, "reset_cb"): preset_class.reset_cb(context) - # execute the preset using script.python_file_run if ext == ".py": - bpy.ops.script.python_file_run(filepath=filepath) + import importlib.util + mod_spec = importlib.util.spec_from_file_location("__main__", filepath) + try: + mod_spec.loader.exec_module(importlib.util.module_from_spec(mod_spec)) + except Exception as ex: + self.report({'ERROR'}, "Failed to executge the preset: " + repr(ex)) + elif ext == ".xml": import rna_xml rna_xml.xml_file_run(context, |