Keymap: support for reading/writing keymaps as data

Instead of running code to create a keymap, store them as data.
This allows for keymaps to share content as well as running
transformations at load time.
This commit is contained in:
Campbell Barton
2018-07-07 19:50:10 +02:00
parent 1f539cd7ef
commit f7bce99e4d
4 changed files with 259 additions and 3 deletions

View File

@@ -581,8 +581,13 @@ def keyconfig_set(filepath, report=None):
try:
error_msg = ""
with open(filepath, 'r', encoding='utf-8') as keyfile:
exec(compile(keyfile.read(), filepath, "exec"),
{"__file__": filepath})
exec(
compile(keyfile.read(), filepath, "exec"),
{
"__file__": filepath,
"__name__": "__main__",
}
)
except:
import traceback
error_msg = traceback.format_exc()