def initialize2(Plugin):

    def _nodeInit():
        nameToAttr = {}
        for attr in Plugin.attributes:
            mattr = attr.create(Plugin)
            Plugin.addAttribute(mattr)
            nameToAttr[attr['name']] = mattr
        for (src, dst) in Plugin.affects:
            log.debug(("'%s' affects '%s'" % (src, dst)))
            Plugin.attributeAffects(nameToAttr[src], nameToAttr[dst])

    def _nodeCreator():
        return Plugin()

    def initializePlugin(obj):
        version = '.'.join(map(str, Plugin.version))
        plugin = om.MFnPlugin(obj, 'Cmdx', version, 'Any')
        try:
            if issubclass(Plugin, LocatorNode):
                plugin.registerNode(Plugin.name, Plugin.typeid, _nodeCreator, _nodeInit, om.MPxNode.kLocatorNode, Plugin.classification)
            elif issubclass(Plugin, DgNode):
                plugin.registerNode(Plugin.name, Plugin.typeid, _nodeCreator, _nodeInit)
            elif issubclass(Plugin, SurfaceShape):
                plugin.registerShape(Plugin.name, Plugin.typeid, _nodeCreator, _nodeInit, Plugin.uiCreator, Plugin.classification)
            else:
                raise TypeError(("Unsupported subclass: '%s'" % Plugin))
        except Exception:
            raise
        else:
            InstalledPlugins[Plugin.name] = Plugin
            Plugin.postInitialize()
    return initializePlugin
def initialize2(Plugin):

    def _nodeInit():
        nameToAttr = {}
        for attr in Plugin.attributes:
            mattr = attr.create(Plugin)
            Plugin.addAttribute(mattr)
            nameToAttr[attr['name']] = mattr
        for (src, dst) in Plugin.affects:
            log.debug(("'%s' affects '%s'" % (src, dst)))
            Plugin.attributeAffects(nameToAttr[src], nameToAttr[dst])

    def _nodeCreator():
        return Plugin()

    def initializePlugin(obj):
        version = '.'.join(map(str, Plugin.version))
        plugin = om.MFnPlugin(obj, 'Cmdx', version, 'Any')
        try:
            if issubclass(Plugin, LocatorNode):
                plugin.registerNode(Plugin.name, Plugin.typeid, _nodeCreator, _nodeInit, om.MPxNode.kLocatorNode, Plugin.classification)
            elif issubclass(Plugin, DgNode):
                plugin.registerNode(Plugin.name, Plugin.typeid, _nodeCreator, _nodeInit)
            elif issubclass(Plugin, SurfaceShape):
                plugin.registerShape(Plugin.name, Plugin.typeid, _nodeCreator, _nodeInit, Plugin.uiCreator, Plugin.classification)
            else:
                raise TypeError(("Unsupported subclass: '%s'" % Plugin))
        except Exception:
            raise
        else:
            InstalledPlugins[Plugin.name] = Plugin
            Plugin.postInitialize()
    return initializePlugin