how to set an Operator to works only in specific space?

how to set an Operator to works only in specific space?

I’m trying to create an armature generator in “Armature edit mode” using a position of some bones to generate a complex bone hierarchy.

I want this operator opears only in editmode of bone like “Switch Direction” does…

I can’t find the option in api reference! :frowning:

import bpy

class BoneBend(bpy.types.Operator):
bl_idname = “wm.bend02”
bl_label = “bend_02”

def execute(self, context):
    BB_ArmatureName = str(bpy.context.active_object)
    BB_BoneName = str(bpy.context.active_bone)
    print (BB_ArmatureName, BB_BoneName)
    self.BondeEditMode()
    self.BondePoseMode()        
    return {'FINISHED'}

def BondeEditMode(self):
    bpy.ops.armature.duplicate()
    bpy.ops.armature.subdivide(number_cuts=1)
        
def BondePoseMode(self):
    bpy.ops.object.posemode_toggle()

bpy.utils.register_class(BoneBend)

insert this before def execute:


...
bl_label = "bend_02"

@classmethod
def poll(self, context):
 return context.mode=="EDIT_ARMATURE"

def execute(self, context):
.....