Fix exported keymaps loading in 2.91 and older

The generated keymaps used a keyword argument that doesn't exist
in older Blender versions.
This commit is contained in:
Campbell Barton 2020-12-17 00:52:04 +11:00
parent 69c3f4a46d
commit 245450b144
1 changed files with 10 additions and 1 deletions

View File

@ -222,12 +222,21 @@ def keyconfig_export_as_data(wm, kc, filepath, *, all_keymaps=False):
fw("]\n")
fw("\n\n")
fw("if __name__ == \"__main__\":\n")
# We could remove this in the future, as loading new key-maps in older Blender versions
# makes less and less sense as Blender changes.
fw(" # Only add keywords that are supported.\n")
fw(" from bpy.app import version as blender_version\n")
fw(" keywords = {}\n")
fw(" if blender_version >= (2, 92, 0):\n")
fw(" keywords[\"keyconfig_version\"] = keyconfig_version\n")
fw(" import os\n")
fw(" from bl_keymap_utils.io import keyconfig_import_from_data\n")
fw(" keyconfig_import_from_data(\n")
fw(" os.path.splitext(os.path.basename(__file__))[0],\n")
fw(" keyconfig_data,\n")
fw(" keyconfig_version=keyconfig_version,\n")
fw(" **keywords,\n")
fw(" )\n")