Exemple #1
0
def _addPluginCommand(pluginName, funcName):
    global _pluginData

    if funcName not in _pluginData[pluginName].setdefault('commands', []):
        _pluginData[pluginName]['commands'].append(funcName)
    _logger.debug("Adding plugin command: {} (plugin: {})".format(
        funcName, pluginName))
    #_logger.debug("adding new command:", funcName)
    _factories.cmdlist[funcName] = _cmdcache.getCmdInfoBasic(funcName)
    _factories.cmdlist[funcName]['plugin'] = pluginName
    _pmcmds.addWrappedCmd(funcName)
    # FIXME: I think we can call a much simpler factory function, because
    # plugins cannnot opt into the complex mutations that functionFactory can apply
    func = _factories.functionFactory(funcName)
    try:
        if func:
            # FIXME: figure out what to do about moduleCmds. could a plugin function be in moduleCmds???
            coreModule = 'pymel.core.%s' % _cmdcache.getModule(
                funcName, {})  # _factories.moduleCmds)
            if coreModule in sys.modules:
                setattr(sys.modules[coreModule], funcName, func)
            # Note that we add the function to both a core module (ie,
            # pymel.core.other), the pymel.core itself, and pymel.all; this
            # way, we mirror the behavior of 'normal' functions
            setattr(_module, funcName, func)
            if 'pymel.all' in sys.modules:
                setattr(sys.modules['pymel.all'], funcName, func)
        else:
            _logger.warning("failed to create function")
    except Exception, msg:
        _logger.warning("exception: %s" % str(msg))
Exemple #2
0
def _addPluginCommand(pluginName, funcName):
    global _pluginData

    if funcName not in _pluginData[pluginName].setdefault('commands', []):
        _pluginData[pluginName]['commands'].append(funcName)
    _logger.debug("Adding command: %s" % funcName)
    #_logger.debug("adding new command:", funcName)
    _factories.cmdlist[funcName] = _cmdcache.getCmdInfoBasic(funcName)
    _factories.cmdlist[funcName]['plugin'] = pluginName
    _pmcmds.addWrappedCmd(funcName)
    func = _factories.functionFactory(funcName)
    try:
        if func:
            coreModule = 'pymel.core.%s' % _cmdcache.getModule(
                funcName, _factories.moduleCmds)
            if coreModule in sys.modules:
                setattr(sys.modules[coreModule], funcName, func)
            # Note that we add the function to both a core module (ie,
            # pymel.core.other), the pymel.core itself, and pymel.all; this
            # way, we mirror the behavior of 'normal' functions
            setattr(_module, funcName, func)
            if 'pymel.all' in sys.modules:
                setattr(sys.modules['pymel.all'], funcName, func)
        else:
            _logger.warning("failed to create function")
    except Exception, msg:
        _logger.warning("exception: %s" % str(msg))
Exemple #3
0
def _addPluginCommand(pluginName, funcName):
    global _pluginData
    
    if funcName not in _pluginData[pluginName].setdefault('commands', []):
        _pluginData[pluginName]['commands'].append(funcName)
    _logger.debug("Adding command: %s" % funcName)
    #_logger.debug("adding new command:", funcName)
    _factories.cmdlist[funcName] = _cmdcache.getCmdInfoBasic( funcName )
    _factories.cmdlist[funcName]['plugin'] = pluginName
    _pmcmds.addWrappedCmd(funcName)
    func = _factories.functionFactory( funcName )
    try:
        if func:
            coreModule = 'pymel.core.%s' % _cmdcache.getModule(funcName,
                                                               _factories.moduleCmds)
            if coreModule in sys.modules:
                setattr( sys.modules[coreModule], funcName, func )
            # Note that we add the function to both a core module (ie,
            # pymel.core.other), the pymel.core itself, and pymel.all; this
            # way, we mirror the behavior of 'normal' functions 
            setattr( _module, funcName, func )
            if 'pymel.all' in sys.modules:
                setattr( sys.modules['pymel.all'], funcName, func )
        else:
            _logger.warning( "failed to create function" )
    except Exception, msg:
        _logger.warning("exception: %s" % str(msg) )