2013-02-26 04:48:16 +00:00
|
|
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software Foundation,
|
|
|
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
#
|
|
|
|
# ##### END GPL LICENSE BLOCK #####
|
|
|
|
|
|
|
|
# <pep8 compliant>
|
|
|
|
|
|
|
|
# simple script to test 'keyconfig_utils' contains correct values.
|
|
|
|
|
|
|
|
|
|
|
|
from bpy_extras import keyconfig_utils
|
|
|
|
|
|
|
|
|
|
|
|
def check_maps():
|
2013-02-26 05:22:04 +00:00
|
|
|
maps = {}
|
2013-02-26 04:48:16 +00:00
|
|
|
|
|
|
|
def fill_maps(ls):
|
2013-02-26 05:22:04 +00:00
|
|
|
for km_name, km_space_type, km_region_type, km_sub in ls:
|
|
|
|
maps[km_name] = (km_space_type, km_region_type)
|
|
|
|
fill_maps(km_sub)
|
2013-02-26 04:48:16 +00:00
|
|
|
|
|
|
|
fill_maps(keyconfig_utils.KM_HIERARCHY)
|
|
|
|
|
|
|
|
import bpy
|
2013-02-26 05:22:04 +00:00
|
|
|
keyconf = bpy.context.window_manager.keyconfigs.active
|
|
|
|
maps_bl = set(keyconf.keymaps.keys())
|
|
|
|
maps_py = set(maps.keys())
|
2013-02-26 04:48:16 +00:00
|
|
|
|
|
|
|
err = False
|
|
|
|
# Check keyconfig contains only maps that exist in blender
|
2013-02-26 05:22:04 +00:00
|
|
|
test = maps_py - maps_bl
|
2013-02-26 04:48:16 +00:00
|
|
|
if test:
|
|
|
|
print("Keymaps that are in 'keyconfig_utils' but not blender")
|
|
|
|
for km_id in sorted(test):
|
|
|
|
print("\t%s" % km_id)
|
|
|
|
err = True
|
|
|
|
|
2013-02-26 05:22:04 +00:00
|
|
|
test = maps_bl - maps_py
|
2013-02-26 04:48:16 +00:00
|
|
|
if test:
|
|
|
|
print("Keymaps that are in blender but not in 'keyconfig_utils'")
|
|
|
|
for km_id in sorted(test):
|
2013-02-26 05:22:04 +00:00
|
|
|
km = keyconf.keymaps[km_id]
|
|
|
|
print(" ('%s', '%s', '%s', [])," % (km_id, km.space_type, km.region_type))
|
2013-02-26 04:48:16 +00:00
|
|
|
err = True
|
|
|
|
|
2013-02-26 05:22:04 +00:00
|
|
|
# Check space/region's are OK
|
|
|
|
print("Comparing keymap space/region types...")
|
|
|
|
for km_id, km in keyconf.keymaps.items():
|
|
|
|
km_py = maps.get(km_id)
|
|
|
|
if km_py is not None:
|
|
|
|
km_space_type, km_region_type = km_py
|
|
|
|
if km_space_type != km.space_type or km_region_type != km.region_type:
|
|
|
|
print(" Error:")
|
|
|
|
print(" expected -- ('%s', '%s', '%s', [])," % (km_id, km.space_type, km.region_type))
|
|
|
|
print(" got -- ('%s', '%s', '%s', [])," % (km_id, km_space_type, km_region_type))
|
|
|
|
print("done!")
|
|
|
|
|
2013-02-26 04:48:16 +00:00
|
|
|
return err
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
err = check_maps()
|
|
|
|
|
2013-02-26 05:22:04 +00:00
|
|
|
import bpy
|
2013-02-26 04:48:16 +00:00
|
|
|
if err and bpy.app.background:
|
|
|
|
# alert CTest we failed
|
|
|
|
import sys
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|