From 7771f0fee3e508674b4852d0ae1f3ae01243ade8 Mon Sep 17 00:00:00 2001
From: Sergey Sharybin <sergey.vfx@gmail.com>
Date: Wed, 18 Jan 2012 20:51:26 +0000
Subject: [PATCH] - Removed dots from the end of description - Check for keymap
 availability to suppress warning messages when running   blender in
 background mode

---
 add_curve_torus_knots.py                      |  2 +-
 .../add_mesh_extra_objects.py                 |  6 +-
 add_mesh_extra_objects/add_mesh_gears.py      |  4 +-
 add_mesh_extra_objects/add_mesh_gemstones.py  |  2 +-
 development_api_navigator.py                  | 12 +--
 io_export_pc2.py                              |  2 +-
 io_export_unreal_psk_psa.py                   | 20 ++---
 io_mesh_pdb/__init__.py                       |  2 +-
 mesh_bsurfaces.py                             | 26 ++++---
 object_add_chain.py                           |  2 +-
 object_fracture/fracture_ops.py               |  8 +-
 rigify/ui.py                                  |  2 +-
 space_view3d_copy_attributes.py               | 73 ++++++++++---------
 space_view3d_materials_utils.py               | 20 ++---
 space_view3d_spacebar_menu.py                 | 22 +++---
 15 files changed, 108 insertions(+), 95 deletions(-)

diff --git a/add_curve_torus_knots.py b/add_curve_torus_knots.py
index 8f832c5aa..bba2afd04 100644
--- a/add_curve_torus_knots.py
+++ b/add_curve_torus_knots.py
@@ -130,7 +130,7 @@ class torus_knot_plus(bpy.types.Operator, AddObjectHelper):
     torus_res = IntProperty(name="Resoulution",
                 default=100,
                 min=3, soft_min=3,
-                description='Resolution, Number of controlverticies.')
+                description='Resolution, Number of controlverticies')
     torus_p = IntProperty(name="p",
                 default=2,
                 min=1, soft_min=1,
diff --git a/add_mesh_extra_objects/add_mesh_extra_objects.py b/add_mesh_extra_objects/add_mesh_extra_objects.py
index 819b9732c..f2f4d8cdb 100644
--- a/add_mesh_extra_objects/add_mesh_extra_objects.py
+++ b/add_mesh_extra_objects/add_mesh_extra_objects.py
@@ -357,7 +357,7 @@ def trapezohedron(s,r,h):
     return verts,faces
 
 class AddSqorus(bpy.types.Operator):
-    '''Add a sqorus mesh.'''
+    '''Add a sqorus mesh'''
     bl_idname = "mesh.primitive_sqorus_add"
     bl_label = "Add Sqorus"
     bl_options = {'REGISTER', 'UNDO', 'PRESET'}
@@ -386,7 +386,7 @@ class AddSqorus(bpy.types.Operator):
 
 
 class AddWedge(bpy.types.Operator):
-    '''Add a wedge mesh.'''
+    '''Add a wedge mesh'''
     bl_idname = "mesh.primitive_wedge_add"
     bl_label = "Add Wedge"
     bl_options = {'REGISTER', 'UNDO', 'PRESET'}
@@ -420,7 +420,7 @@ class AddWedge(bpy.types.Operator):
 
 
 class AddStar(bpy.types.Operator):
-    '''Add a star mesh.'''
+    '''Add a star mesh'''
     bl_idname = "mesh.primitive_star_add"
     bl_label = "Add Star"
     bl_options = {'REGISTER', 'UNDO', 'PRESET'}
diff --git a/add_mesh_extra_objects/add_mesh_gears.py b/add_mesh_extra_objects/add_mesh_gears.py
index 0a0ba8d8a..8b35ffca0 100644
--- a/add_mesh_extra_objects/add_mesh_gears.py
+++ b/add_mesh_extra_objects/add_mesh_gears.py
@@ -570,7 +570,7 @@ def add_worm(teethNum, rowNum, radius, Ad, De, p_angle,
 
 
 class AddGear(bpy.types.Operator):
-    '''Add a gear mesh.'''
+    '''Add a gear mesh'''
     bl_idname = "mesh.primitive_gear"
     bl_label = "Add Gear"
     bl_options = {'REGISTER', 'UNDO', 'PRESET'}
@@ -676,7 +676,7 @@ class AddGear(bpy.types.Operator):
 
 
 class AddWormGear(bpy.types.Operator):
-    '''Add a worm gear mesh.'''
+    '''Add a worm gear mesh'''
     bl_idname = "mesh.primitive_worm_gear"
     bl_label = "Add Worm Gear"
     bl_options = {'REGISTER', 'UNDO', 'PRESET'}
diff --git a/add_mesh_extra_objects/add_mesh_gemstones.py b/add_mesh_extra_objects/add_mesh_gemstones.py
index 7c25f935c..378ee072d 100644
--- a/add_mesh_extra_objects/add_mesh_gemstones.py
+++ b/add_mesh_extra_objects/add_mesh_gemstones.py
@@ -238,7 +238,7 @@ def add_diamond(segments, girdle_radius, table_radius,
 
 
 class AddDiamond(bpy.types.Operator):
-    '''Add a diamond mesh.'''
+    '''Add a diamond mesh'''
     bl_idname = "mesh.primitive_diamond_add"
     bl_label = "Add Diamond"
     bl_options = {'REGISTER', 'UNDO', 'PRESET'}
diff --git a/development_api_navigator.py b/development_api_navigator.py
index 32cf8aa2c..280363bd1 100644
--- a/development_api_navigator.py
+++ b/development_api_navigator.py
@@ -659,15 +659,17 @@ class OBJECT_PT_api_navigator(ApiNavigator, bpy.types.Panel):
 
 def register_keymaps():
     kc = bpy.context.window_manager.keyconfigs.addon
-    km = kc.keymaps.new(name="Text", space_type='TEXT_EDITOR')
-    km.keymap_items.new('api_navigator.toggle_doc', 'ESC', 'PRESS')
+    if kc:
+        km = kc.keymaps.new(name="Text", space_type='TEXT_EDITOR')
+        km.keymap_items.new('api_navigator.toggle_doc', 'ESC', 'PRESS')
 
 
 def unregister_keymaps():
     kc = bpy.context.window_manager.keyconfigs.addon
-    km = kc.keymaps["Text"]
-    kmi = km.keymap_items["api_navigator.toggle_doc"]
-    km.keymap_items.remove(kmi)
+    if kc:
+        km = kc.keymaps["Text"]
+        kmi = km.keymap_items["api_navigator.toggle_doc"]
+        km.keymap_items.remove(kmi)
 
 
 def register():
diff --git a/io_export_pc2.py b/io_export_pc2.py
index 777ddac95..b09d5a732 100644
--- a/io_export_pc2.py
+++ b/io_export_pc2.py
@@ -105,7 +105,7 @@ def do_export(context, props, filepath):
 
 ###### EXPORT OPERATOR #######
 class Export_pc2(bpy.types.Operator, ExportHelper):
-    '''Exports the active Object as a .pc2 Pointcache file.'''
+    '''Exports the active Object as a .pc2 Pointcache file'''
     bl_idname = "export_shape.pc2"
     bl_label = "Export Pointcache (.pc2)"
 
diff --git a/io_export_unreal_psk_psa.py b/io_export_unreal_psk_psa.py
index 4c409c858..5153eed10 100644
--- a/io_export_unreal_psk_psa.py
+++ b/io_export_unreal_psk_psa.py
@@ -1808,7 +1808,7 @@ bpy.types.Scene.unrealfpsrate = IntProperty(
     
 bpy.types.Scene.unrealexport_settings = EnumProperty(
     name="Export:",
-    description="Select a export settings (psk/psa/all)...",
+    description="Select a export settings (psk/psa/all)",
     items = [("0","PSK","Export PSK"),
              ("1","PSA","Export PSA"),
              ("2","ALL","Export ALL")],
@@ -1824,7 +1824,7 @@ bpy.types.Scene.UEActionSetSettings = EnumProperty(
 
 bpy.types.Scene.unrealtriangulatebool = BoolProperty(
     name="Triangulate Mesh",
-    description="Convert Quad to Tri Mesh Boolean...",
+    description="Convert Quad to Tri Mesh Boolean",
     default=False)
 
 bpy.types.Scene.unrealignoreactionmatchcount = BoolProperty(
@@ -1872,7 +1872,7 @@ bpy.types.Object.myCollectionUEA_index = bpy.props.IntProperty(min = -1, default
 class OBJECT_OT_add_remove_Collection_Items_UE(bpy.types.Operator):
     bl_label = "Add or Remove"
     bl_idname = "collection.add_remove_ueactions"
-    __doc__ = """Button for Add, Remove, Refresh Action Set(s) list."""
+    __doc__ = """Button for Add, Remove, Refresh Action Set(s) list"""
     set = bpy.props.StringProperty()
  
     def invoke(self, context, event):
@@ -1931,7 +1931,7 @@ class ExportUDKAnimData(bpy.types.Operator):
     '''Export Skeleton Mesh / Animation Data file(s)'''
     bl_idname = "export_anim.udk" # this is important since its how bpy.ops.export.udk_anim_data is constructed
     bl_label = "Export PSK/PSA"
-    __doc__ = """One mesh and one armature else select one mesh or armature to be exported."""
+    __doc__ = """One mesh and one armature else select one mesh or armature to be exported"""
 
     # List of operator properties, the attributes will be assigned
     # to the class instance from the operator settings before calling.
@@ -2067,7 +2067,7 @@ class OBJECT_OT_UnrealExport(bpy.types.Operator):
     global exportmessage
     bl_idname = "export_mesh.udk"  # XXX, name???
     bl_label = "Unreal Export"
-    __doc__ = """Select export setting for .psk/.psa or both."""
+    __doc__ = """Select export setting for .psk/.psa or both"""
     
     def invoke(self, context, event):
         print("Init Export Script:")
@@ -2094,7 +2094,7 @@ class OBJECT_OT_ToggleConsle(bpy.types.Operator):
     global exportmessage
     bl_idname = "object.toggleconsle"  # XXX, name???
     bl_label = "Toggle Console"
-    __doc__ = "Show or Hide Console."
+    __doc__ = "Show or Hide Console"
     
     def invoke(self, context, event):
         bpy.ops.wm.console_toggle()
@@ -2103,7 +2103,7 @@ class OBJECT_OT_ToggleConsle(bpy.types.Operator):
 class OBJECT_OT_UTSelectedFaceSmooth(bpy.types.Operator):
     bl_idname = "object.utselectfacesmooth"  # XXX, name???
     bl_label = "Select Smooth faces"
-    __doc__ = """It will only select smooth faces that is select mesh."""
+    __doc__ = """It will only select smooth faces that is select mesh"""
     
     def invoke(self, context, event):
         print("----------------------------------------")
@@ -2158,7 +2158,7 @@ class OBJECT_OT_DeleteActionSet(bpy.types.Operator):
 class OBJECT_OT_MeshClearWeights(bpy.types.Operator):
     bl_idname = "object.meshclearweights"  # XXX, name???
     bl_label = "Mesh Clear Weights"
-    __doc__ = """Clear selected mesh vertex group weights for the bones. Be sure you unparent the armature."""
+    __doc__ = """Clear selected mesh vertex group weights for the bones. Be sure you unparent the armature"""
     
     def invoke(self, context, event):
         for obj in bpy.data.objects:
@@ -2171,7 +2171,7 @@ class OBJECT_OT_MeshClearWeights(bpy.types.Operator):
 class OBJECT_OT_UTRebuildArmature(bpy.types.Operator):
     bl_idname = "object.utrebuildarmature"  # XXX, name???
     bl_label = "Rebuild Armature"
-    __doc__ = """If mesh is deform when importing to unreal engine try this. It rebuild the bones one at the time by select one armature object scrape to raw setup build. Note the scale will be 1:1 for object mode. To keep from deforming."""
+    __doc__ = """If mesh is deform when importing to unreal engine try this. It rebuild the bones one at the time by select one armature object scrape to raw setup build. Note the scale will be 1:1 for object mode. To keep from deforming"""
     
     def invoke(self, context, event):
         print("----------------------------------------")
@@ -2242,7 +2242,7 @@ def unpack_list(list_of_tuples):
 class OBJECT_OT_UTRebuildMesh(bpy.types.Operator):
     bl_idname = "object.utrebuildmesh"  # XXX, name???
     bl_label = "Rebuild Mesh"
-    __doc__ = """It rebuild the mesh from scrape from the selected mesh object. Note the scale will be 1:1 for object mode. To keep from deforming."""
+    __doc__ = """It rebuild the mesh from scrape from the selected mesh object. Note the scale will be 1:1 for object mode. To keep from deforming"""
     
     def invoke(self, context, event):
         print("----------------------------------------")
diff --git a/io_mesh_pdb/__init__.py b/io_mesh_pdb/__init__.py
index 76fb7f72d..e079ff3d5 100644
--- a/io_mesh_pdb/__init__.py
+++ b/io_mesh_pdb/__init__.py
@@ -234,7 +234,7 @@ class CLASS_atom_pdb_IO(bpy.types.PropertyGroup):
         description="The sticks are round (sectors are not visible)")     
     scn.use_atom_pdb_sticks_bonds = BoolProperty(
         name="Bonds", default=False,
-        description="Show double and tripple bonds.")
+        description="Show double and tripple bonds")
     scn.atom_pdb_sticks_dist = FloatProperty(
         name="Distance", default = 1.1, min=1.0, max=3.0,
         description="Distance between sticks measured in stick diameter")        
diff --git a/mesh_bsurfaces.py b/mesh_bsurfaces.py
index 07d16ea90..b51d80f56 100644
--- a/mesh_bsurfaces.py
+++ b/mesh_bsurfaces.py
@@ -822,9 +822,10 @@ def register():
     bpy.types.Scene.SURFSK_keep_strokes = bpy.props.BoolProperty(name="Keep strokes", description="Keeps the sketched strokes after adding the surface", default=False)
 
     kc = bpy.context.window_manager.keyconfigs.addon
-    km = kc.keymaps.new(name="3D View", space_type="VIEW_3D")
-    keymap_item_add_surf = km.keymap_items.new("gpencil.surfsk_add_surface","E","PRESS", key_modifier="D")
-    keymap_item_stroke_to_curve = km.keymap_items.new("gpencil.surfsk_strokes_to_curves","C","PRESS", key_modifier="D")
+    if kc:
+        km = kc.keymaps.new(name="3D View", space_type="VIEW_3D")
+        keymap_item_add_surf = km.keymap_items.new("gpencil.surfsk_add_surface","E","PRESS", key_modifier="D")
+        keymap_item_stroke_to_curve = km.keymap_items.new("gpencil.surfsk_strokes_to_curves","C","PRESS", key_modifier="D")
     
 
 def unregister():
@@ -838,15 +839,16 @@ def unregister():
     del bpy.types.Scene.SURFSK_keep_strokes
     
     kc = bpy.context.window_manager.keyconfigs.addon
-    km = kc.keymaps["3D View"]
-    for kmi in km.keymap_items:
-        if kmi.idname == 'wm.call_menu':
-            if kmi.properties.name == "GPENCIL_OT_SURFSK_add_surface":
-                km.keymap_items.remove(kmi)
-            elif kmi.properties.name == "GPENCIL_OT_SURFSK_strokes_to_curves":
-                km.keymap_items.remove(kmi)   
-            else:
-                continue
+    if kc:
+        km = kc.keymaps["3D View"]
+        for kmi in km.keymap_items:
+            if kmi.idname == 'wm.call_menu':
+                if kmi.properties.name == "GPENCIL_OT_SURFSK_add_surface":
+                    km.keymap_items.remove(kmi)
+                elif kmi.properties.name == "GPENCIL_OT_SURFSK_strokes_to_curves":
+                    km.keymap_items.remove(kmi)   
+                else:
+                    continue
 
     
 if __name__ == "__main__":
diff --git a/object_add_chain.py b/object_add_chain.py
index f86a81761..8b30264c3 100644
--- a/object_add_chain.py
+++ b/object_add_chain.py
@@ -142,7 +142,7 @@ def Add_Chain():
 
 #makes AddChain an operator
 class AddChain(bpy.types.Operator):
-    '''Add a Chain.'''
+    '''Add a Chain'''
     bl_idname = "mesh.primitive_chain_add"
     bl_label = "Add Chain"
     bl_options = {'REGISTER', 'UNDO'}
diff --git a/object_fracture/fracture_ops.py b/object_fracture/fracture_ops.py
index fb609b67d..61ccc1825 100644
--- a/object_fracture/fracture_ops.py
+++ b/object_fracture/fracture_ops.py
@@ -342,13 +342,13 @@ def fracture_group(context, group):
 
 
 class FractureSimple(bpy.types.Operator):
-    '''Split object with boolean operations for simulation, uses an object.'''
+    '''Split object with boolean operations for simulation, uses an object'''
     bl_idname = "object.fracture_simple"
     bl_label = "Fracture Object"
     bl_options = {'REGISTER', 'UNDO'}
 
     exe = BoolProperty(name="Execute",
-        description="If it shall actually run, for optimal performance...",
+        description="If it shall actually run, for optimal performance",
         default=False)
 
     hierarchy = BoolProperty(name="Generate hierarchy",
@@ -388,13 +388,13 @@ class FractureSimple(bpy.types.Operator):
 
 
 class FractureGroup(bpy.types.Operator):
-    '''Split object with boolean operations for simulation, uses a group.'''
+    '''Split object with boolean operations for simulation, uses a group'''
     bl_idname = "object.fracture_group"
     bl_label = "Fracture Object (Group)"
     bl_options = {'REGISTER', 'UNDO'}
 
     exe = BoolProperty(name="Execute",
-                       description="If it shall actually run, for optimal performance...",
+                       description="If it shall actually run, for optimal performance",
                        default=False)
 
     group = StringProperty(name="Group",
diff --git a/rigify/ui.py b/rigify/ui.py
index d42c96dae..f4e8c43ac 100644
--- a/rigify/ui.py
+++ b/rigify/ui.py
@@ -251,7 +251,7 @@ class Generate(bpy.types.Operator):
 
 
 class Sample(bpy.types.Operator):
-    '''Create a sample metarig to be modified before generating the final rig.'''
+    '''Create a sample metarig to be modified before generating the final rig'''
 
     bl_idname = "armature.metarig_sample_add"
     bl_label = "Add a sample metarig for a rig type"
diff --git a/space_view3d_copy_attributes.py b/space_view3d_copy_attributes.py
index f26307598..18b9f518d 100644
--- a/space_view3d_copy_attributes.py
+++ b/space_view3d_copy_attributes.py
@@ -738,49 +738,52 @@ def register():
 
     ''' mostly to get the keymap working '''
     kc = bpy.context.window_manager.keyconfigs.addon
-    km = kc.keymaps.new(name="Object Mode")
-    kmi = km.keymap_items.new('wm.call_menu', 'C', 'PRESS', ctrl=True)
-    kmi.properties.name = 'VIEW3D_MT_copypopup'
-
-    km = kc.keymaps.new(name="Pose")
-    kmi = km.keymap_items.get("pose.copy")
-    if kmi is not None:
-        kmi.idname = 'wm.call_menu'
-    else:
+    if kc:
+        km = kc.keymaps.new(name="Object Mode")
         kmi = km.keymap_items.new('wm.call_menu', 'C', 'PRESS', ctrl=True)
-    kmi.properties.name = 'VIEW3D_MT_posecopypopup'
-    for menu in _layer_menus:
-        bpy.utils.register_class(menu)
+        kmi.properties.name = 'VIEW3D_MT_copypopup'
+
+        km = kc.keymaps.new(name="Pose")
+        kmi = km.keymap_items.get("pose.copy")
+        if kmi is not None:
+            kmi.idname = 'wm.call_menu'
+        else:
+            kmi = km.keymap_items.new('wm.call_menu', 'C', 'PRESS', ctrl=True)
+        kmi.properties.name = 'VIEW3D_MT_posecopypopup'
+        for menu in _layer_menus:
+            bpy.utils.register_class(menu)
 
-    km = kc.keymaps.new(name="Mesh")
-    kmi = km.keymap_items.new('wm.call_menu', 'C', 'PRESS')
-    kmi.ctrl = True
-    kmi.properties.name = 'MESH_MT_CopyFaceSettings'
+        km = kc.keymaps.new(name="Mesh")
+        kmi = km.keymap_items.new('wm.call_menu', 'C', 'PRESS')
+        kmi.ctrl = True
+        kmi.properties.name = 'MESH_MT_CopyFaceSettings'
 
 
 def unregister():
     bpy.utils.unregister_module(__name__)
 
     ''' mostly to remove the keymap '''
-    kms = bpy.context.window_manager.keyconfigs.addon.keymaps['Pose']
-    for item in kms.keymap_items:
-        if item.name == 'Call Menu' and item.idname == 'wm.call_menu' and \
-           item.properties.name == 'VIEW3D_MT_posecopypopup':
-            item.idname = 'pose.copy'
-            break
-    for menu in _layer_menus:
-        bpy.utils.unregister_class(menu)
-    km = bpy.context.window_manager.keyconfigs.addon.keymaps['Mesh']
-    for kmi in km.keymap_items:
-        if kmi.idname == 'wm.call_menu':
-            if kmi.properties.name == 'MESH_MT_CopyFaceSettings':
-                km.keymap_items.remove(kmi)
-
-    km = bpy.context.window_manager.keyconfigs.addon.keymaps['Object Mode']
-    for kmi in km.keymap_items:
-        if kmi.idname == 'wm.call_menu':
-            if kmi.properties.name == 'VIEW3D_MT_copypopup':
-                km.keymap_items.remove(kmi)
+    kc = bpy.context.window_manager.keyconfigs.addon
+    if kc:
+        kms = kc.keymaps['Pose']
+        for item in kms.keymap_items:
+            if item.name == 'Call Menu' and item.idname == 'wm.call_menu' and \
+               item.properties.name == 'VIEW3D_MT_posecopypopup':
+                item.idname = 'pose.copy'
+                break
+        for menu in _layer_menus:
+            bpy.utils.unregister_class(menu)
+        km = kc.keymaps['Mesh']
+        for kmi in km.keymap_items:
+            if kmi.idname == 'wm.call_menu':
+                if kmi.properties.name == 'MESH_MT_CopyFaceSettings':
+                    km.keymap_items.remove(kmi)
+
+        km = kc.addon.keymaps['Object Mode']
+        for kmi in km.keymap_items:
+            if kmi.idname == 'wm.call_menu':
+                if kmi.properties.name == 'VIEW3D_MT_copypopup':
+                    km.keymap_items.remove(kmi)
 
 if __name__ == "__main__":
     register()
diff --git a/space_view3d_materials_utils.py b/space_view3d_materials_utils.py
index 994a74b3f..192c3312f 100644
--- a/space_view3d_materials_utils.py
+++ b/space_view3d_materials_utils.py
@@ -692,21 +692,23 @@ def register():
     bpy.utils.register_module(__name__)
 
     kc = bpy.context.window_manager.keyconfigs.addon
-    km = kc.keymaps.new(name="3D View", space_type="VIEW_3D")
-    kmi = km.keymap_items.new('wm.call_menu', 'Q', 'PRESS')
-    kmi.properties.name = "VIEW3D_MT_master_material"
+    if kc:
+        km = kc.keymaps.new(name="3D View", space_type="VIEW_3D")
+        kmi = km.keymap_items.new('wm.call_menu', 'Q', 'PRESS')
+        kmi.properties.name = "VIEW3D_MT_master_material"
 
 
 def unregister():
     bpy.utils.unregister_module(__name__)
 
     kc = bpy.context.window_manager.keyconfigs.addon
-    km = kc.keymaps["3D View"]
-    for kmi in km.keymap_items:
-        if kmi.idname == 'wm.call_menu':
-            if kmi.properties.name == "VIEW3D_MT_master_material":
-                km.keymap_items.remove(kmi)
-                break
+    if kc:
+        km = kc.keymaps["3D View"]
+        for kmi in km.keymap_items:
+            if kmi.idname == 'wm.call_menu':
+                if kmi.properties.name == "VIEW3D_MT_master_material":
+                    km.keymap_items.remove(kmi)
+                    break
 
 if __name__ == "__main__":
     register()
diff --git a/space_view3d_spacebar_menu.py b/space_view3d_spacebar_menu.py
index 68bbf3f2f..edfc33628 100644
--- a/space_view3d_spacebar_menu.py
+++ b/space_view3d_spacebar_menu.py
@@ -1394,20 +1394,24 @@ def register():
     bpy.utils.register_module(__name__)
 
     wm = bpy.context.window_manager
-    km = wm.keyconfigs.addon.keymaps.new(name='3D View', space_type='VIEW_3D')
-    kmi = km.keymap_items.new('wm.call_menu', 'SPACE', 'PRESS')
-    kmi.properties.name = "VIEW3D_MT_Space_Dynamic_Menu"
+    kc = wm.keyconfigs.addon
+    if kc:
+        km = kc.keymaps.new(name='3D View', space_type='VIEW_3D')
+        kmi = km.keymap_items.new('wm.call_menu', 'SPACE', 'PRESS')
+        kmi.properties.name = "VIEW3D_MT_Space_Dynamic_Menu"
 
 def unregister():
     bpy.utils.unregister_module(__name__)
 
     wm = bpy.context.window_manager
-    km = wm.keyconfigs.addon.keymaps['3D View']
-    for kmi in km.keymap_items:
-        if kmi.idname == 'wm.call_menu':
-            if kmi.properties.name == "VIEW3D_MT_Space_Dynamic_Menu":
-                km.keymap_items.remove(kmi)
-                break
+    kc = wm.keyconfigs.addon
+    if kc:
+        km = kc.addon.keymaps['3D View']
+        for kmi in km.keymap_items:
+            if kmi.idname == 'wm.call_menu':
+                if kmi.properties.name == "VIEW3D_MT_Space_Dynamic_Menu":
+                    km.keymap_items.remove(kmi)
+                    break
 
 if __name__ == "__main__":
     register()
-- 
GitLab