def set_context_layer(self):
    nt = bpy.context.scene.node_tree
    context_layer = None
    for node in bpy.context.scene.node_tree.nodes:
        if (node.name == f'RSN {bpy.context.window.view_layer.name} Render Layers'):
            context_layer = node
    if (not context_layer):
        context_layer = nt.nodes.new(type='CompositorNodeRLayers')
        context_layer.name = f'RSN {bpy.context.window.view_layer.name} Render Layers'
    try:
        com = bpy.context.scene.node_tree.nodes['Composite']
        nt.links.new(context_layer.outputs[0], com.inputs[0])
    except Exception as e:
        self.report({'ERROR'}, 'No Composite Node Found(Check its name must be "Composite") ')
def set_context_layer(self):
    nt = bpy.context.scene.node_tree
    context_layer = None
    for node in bpy.context.scene.node_tree.nodes:
        if (node.name == f'RSN {bpy.context.window.view_layer.name} Render Layers'):
            context_layer = node
    if (not context_layer):
        context_layer = nt.nodes.new(type='CompositorNodeRLayers')
        context_layer.name = f'RSN {bpy.context.window.view_layer.name} Render Layers'
    try:
        com = bpy.context.scene.node_tree.nodes['Composite']
        nt.links.new(context_layer.outputs[0], com.inputs[0])
    except Exception as e:
        self.report({'ERROR'}, 'No Composite Node Found(Check its name must be "Composite") ')