예제 #1
0
파일: syntax.py 프로젝트: oglops/logcatMaya
    def _cmdsFunctionFormat(self):
        '''set up maya.cmds functions'''
        # mayaBinDir = os.path.dirname(sys.executable)
        # cmdsList = os.path.join(mayaBinDir, 'commandList')

        functions = '\\b('
        # with open(cmdsList) as phile:
        #     for line in phile:
        #         functions += line.split(' ')[0] + '|'

        maya_ver=utils.get_maya_version()
        maya_commands = utils.get_commands(version=maya_ver)
        for c in maya_commands:
            functions += c + '|'




        # global MEL procedures
        try:
            melProcedures = cmds.melInfo()
            maxlen = 1400
            stop = len(melProcedures) / maxlen
            melProc = []
            melProc.append('\\b(' + '|'.join(melProcedures[:maxlen]) + ')\\b')
            for i in range(1, stop - 1):
                start = maxlen * i
                end = maxlen * (i + 1)
                melProc.append('\\b(' + '|'.join(melProcedures[start:end]) + ')\\b')
            melProc.append('\\b(' + '|'.join(melProcedures[maxlen*stop:]) + ')\\b')
        except:
            pass

        # TODO: should update it when a plug-in was load.
        try:
            # function from plug-ins
            plugins = cmds.pluginInfo(q=1, listPlugins=1)
            for plugin in plugins:
                funcFromPlugin = cmds.pluginInfo(plugin, q=1, command=1)
                if funcFromPlugin:
                    functions += '|'.join(funcFromPlugin)
        except:
            pass

        functions = functions[:-1] + ')\\b'

        # function format
        funcFormat = QtGui.QTextCharFormat()
        funcFormat.setForeground(self._keywordColor)
        self.__rules.append((re.compile(functions), funcFormat))
        try:
            for mp in melProc:
                self.__rules.append((re.compile(mp), funcFormat))
        except:
            pass
예제 #2
0
    def _cmdsFunctionFormat(self):
        '''set up maya.cmds functions'''
        # mayaBinDir = os.path.dirname(sys.executable)
        # cmdsList = os.path.join(mayaBinDir, 'commandList')

        functions = '\\b('
        # with open(cmdsList) as phile:
        #     for line in phile:
        #         functions += line.split(' ')[0] + '|'

        maya_ver = utils.get_maya_version()
        maya_commands = utils.get_commands(version=maya_ver)
        for c in maya_commands:
            functions += c + '|'

        # global MEL procedures
        try:
            melProcedures = cmds.melInfo()
            maxlen = 1400
            stop = len(melProcedures) / maxlen
            melProc = []
            melProc.append('\\b(' + '|'.join(melProcedures[:maxlen]) + ')\\b')
            for i in range(1, stop - 1):
                start = maxlen * i
                end = maxlen * (i + 1)
                melProc.append('\\b(' + '|'.join(melProcedures[start:end]) +
                               ')\\b')
            melProc.append('\\b(' + '|'.join(melProcedures[maxlen * stop:]) +
                           ')\\b')
        except:
            pass

        # TODO: should update it when a plug-in was load.
        try:
            # function from plug-ins
            plugins = cmds.pluginInfo(q=1, listPlugins=1)
            for plugin in plugins:
                funcFromPlugin = cmds.pluginInfo(plugin, q=1, command=1)
                if funcFromPlugin:
                    functions += '|'.join(funcFromPlugin)
        except:
            pass

        functions = functions[:-1] + ')\\b'

        # function format
        funcFormat = QtGui.QTextCharFormat()
        funcFormat.setForeground(self._keywordColor)
        self.__rules.append((re.compile(functions), funcFormat))
        try:
            for mp in melProc:
                self.__rules.append((re.compile(mp), funcFormat))
        except:
            pass
예제 #3
0
    def __init__later(self):
        self.attributes = []
        self.commandsMel = sorted(maya_cmds.melInfo(),
                                  key=lambda sMel: sMel.lower())
        self.commandsPython = sorted(
            [s[0] for s in getmembers(maya_cmds, callable)],
            key=lambda sPyt: sPyt.lower())
        self.variables = sorted(mel_eval('env'), key=lambda sVar: sVar.lower())

        self.listPtr = self.commandsMel

        self.window.Label_CountAll.setText(str(len(self.commandsMel)))
        self.window.setEnabled(True)
    def _cmdsFunctionFormat(self):
        '''set up maya.cmds functions'''
        mayaBinDir = os.path.dirname(sys.executable)
        cmdsList = os.path.join(mayaBinDir, 'commandList')
        functions = []
        with open(cmdsList) as phile:
            [functions.append(line.split(' ')[0]) for line in phile]

        # global MEL procedures
        functions += cmds.melInfo()

        # TODO: should update it when a plug-in was load.
        # function from plug-ins
        plugins = cmds.pluginInfo(q=1, listPlugins=1)
        for plugin in plugins:
            funcFromPlugin = cmds.pluginInfo(plugin, q=1, command=1)
            if funcFromPlugin:
                functions.extend(funcFromPlugin)

        # function format
        funcFormat = QtGui.QTextCharFormat()
        funcFormat.setForeground(self._keywordColor)
        self.__rules += [('\\b%s\\b' % func, funcFormat) for
                        func in functions]