예제 #1
0
파일: __init__.py 프로젝트: rusn07/pymel
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))
예제 #2
0
파일: __init__.py 프로젝트: CountZer0/pymel
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) )
예제 #3
0
파일: __init__.py 프로젝트: pbiswal/pymel
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))
예제 #4
0
파일: __init__.py 프로젝트: kinetifex/pymel
def _pluginLoaded( *args ):

    if len(args) > 1:
        # 2009 API callback, the args are ( [ pathToPlugin, pluginName ], clientData )
        pluginName = args[0][1]
    else:
        pluginName = args[0]

    if not pluginName:
        return

    _logger.debug("Plugin loaded: %s", pluginName)

    _pluginData[pluginName] = {}

    try:
        commands = _pmcmds.pluginInfo(pluginName, query=1, command=1)
    except:
        _logger.error("Failed to get command list from %s", pluginName)
        commands = None


    # Commands
    if commands:
        _pluginData[pluginName]['commands'] = commands
        _logger.debug( "adding new commands: %s" % ', '.join(commands) )
        for funcName in commands:
            _logger.debug("Adding command: %s..." % funcName)
            #__logger.debug("adding new command:", funcName)
            _factories.cmdlist[funcName] = _factories.cmdcache.getCmdInfoBasic( funcName )
            _pmcmds.addWrappedCmd(funcName)
            func = _factories.functionFactory( funcName )
            try:
                if func:
                    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) )
            _logger.debug("Done adding command %s" % funcName)