def PCSMenu_build(self):
        """ Recursive portion """

        #0. Build base
        if not cmds.menuItem(self.menuName, q=1, ex=1):
            self.PCSMenu = Menu(self.menuName, parent=melGlobals['gMainWindow'], allowOptionBoxes=1, tearOff=1,
                                label=self.PCStoolName)
        else:
            self.PCSMenu = Menu(self.menuName)

        with self.PCSMenu:
            with subMenuItem('Options', label="Options", tearOff=1, allowOptionBoxes=1):
                menuItem(label='Refresh Menu', command=self.PCSMenu_refresh)  # @UndefinedVariable
                mel.eval('source "%s/mel/ca_Strings.mel"' % self.PCSmenuPath)
                mel.eval('source "%s/mel/ca_UIFunctions.mel"' % self.PCSmenuPath)  # @UndefinedVariable
                menuItem(divider=1)  # @UndefinedVariable
            with subMenuItem(label="Docs", tearOff=1, allowOptionBoxes=1):
                menuItem(label='Docs01')  # @UndefinedVariable
            menuItem(divider=1)  # @UndefinedVariable

        # 1. Build a construction dictionary with {folder=[files]}
        for root, unused, unused in os.walk(os.path.abspath(self.PCSmenuStart)):
            if not pcsPath.Path(root).makePretty(0, 0) == self.PCSmenuStart:
                mFiles = []
                for fname in os.listdir(root):
                    fullPath = '%s/%s' % (root, fname)
                    # noinspection PyArgumentList
                    if pcsPath.Path(fullPath).isfile() and (
                            fnmatch.fnmatch(fname, '*.mel') or fnmatch.fnmatch(fname, '*.div')):
                        mFiles.append(fname)
                self.menuDict[pcsPath.Path(root).makePretty(0, 0)] = mFiles

        # 2. Sorted Keys list
        sKeys = []
        for dr in self.menuDict.iterkeys():
            sKeys.append(dr)
        sKeys.sort()

        # 3. Build Sorted Menu
        for s in sKeys:
            # Store & Sort The Files
            dictFiles = self.menuDict[s]
            dictFiles.sort()
            # Store the menuName
            cMainName = s.replace(self.PCSmenuStart, self.PCStPad).replace('/', '_').replace('\\', '_')
            # Store the menuLabel
            if len(s.namebase.split('_')) > 1:
                cMainLabel = s.namebase.split('_')[len(s.namebase.split('_')) - 1]
            else:
                cMainLabel = s.namebase
            # Store the parent of the menu
            cMainParent = s.dirname()
            if cMainParent == self.PCSmenuStart:
                cMainParent = self.PCSMenu
            else:
                cMainParent = cMainParent.replace(self.PCSmenuStart, self.PCStPad).replace('/', '_')
            # Intercept Folder Divider
            if re.search('_div', str(s)):
                cmds.menuItem(p=cMainParent, divider=1)
            else:
                #with subMenuItem(cMainName, parent=cMainParent, label=cMainLabel, tearOff=1, allowOptionBoxes=1):
                with subMenuItem(cMainName, label=cMainLabel, tearOff=1, allowOptionBoxes=1):
                    if dictFiles:
                        for dFile in dictFiles:
                            # Intercept File Divider
                            if re.search('.div', dFile):
                                menuItem(divider=1)  # @UndefinedVariable
                            else:
                                # Mel file with no extension (this is a string of the mel file name)
                                fName = dFile.split('.')[0]
                                # Full Path to Mel File
                                sPath = '%s/%s' % (s, fName)
                                rtCommand = "mel.source('%s')\nmel.%s()" % (sPath, fName)
                                # Make Run Time Command Name
                                rtName = '%s_%s' % (self.PCStPad, fName)
                                # If the run time command doesn't exist
                                if not runTimeCommand(rtName, q=1, ex=1):  # @UndefinedVariable
                                    runTimeCommand(rtName, commandLanguage="python", annotation=self.runTimeAnnotation,
                                                   category=self.PCStoolName, command=rtCommand)  # @UndefinedVariable
                                    runTimeCommand(edit=1, category=self.PCStoolName, save=1)  # @UndefinedVariable
                                # If the run time command does exist
                                else:
                                    existingRTCommand = runTimeCommand(rtName, q=1, command=1)  # @UndefinedVariable
                                    if not existingRTCommand == rtCommand:
                                        runTimeCommand(rtName, e=1, command=rtCommand)  # @UndefinedVariable
                                        runTimeCommand(edit=1, category=self.PCStoolName, save=1)  # @UndefinedVariable

                                # Look for matching icon for menu item
                                icon = ''
                                if os.path.exists('%s.bmp' % sPath):
                                    icon = '%s.bmp' % sPath
                                if os.path.exists('%s.png' % sPath):
                                    icon = '%s.png' % sPath
                                if icon:
                                    menuItem(label=fName, command='python("mel.%s()")' % rtName,
                                             image=icon)  # @UndefinedVariable
                                else:
                                    menuItem(label=fName, command='python("mel.%s()")' % rtName)  # @UndefinedVariable
                                # Intercept the engineA exporter
                                if fName == 'objectExporter':
                                    # Source the option box
                                    mel.eval('source "%s/mel/engineA/objectExporterOptions.mel"' % self.PCSmenuPath)
                                    # Connect command with proc
                                    menuItem(optionBox=1,
                                             command='python("mel.objectExporterOptions()")')  # @UndefinedVariable
                                else:
                                    # Look for matching option box item
                                    if os.path.exists('%s.opb' % sPath):
                                        mel.eval('source "%s/mel/ca_Strings.mel"' % self.PCSmenuPath)
                                        mel.eval('source "%s/mel/ca_UIFunctions.mel"' % self.PCSmenuPath)
                                        menuItem(optionBox=1,
                                                 command='python("mel.ca_descriptWin(\'%s.opb\', \'%s\')")' % (
                                                     sPath, fName))  # @UndefinedVariable

                        # Divider between Commands and Folders
                        menuItem(divider=1)  # @UndefinedVariable

    # noinspection PyUnusedLocal
dataset/ETHPy150Open CountZer0/PipelineConstructionSet/python/maya/core/sysGlobalMenu.py/MayaMenu.PCSMenu_build/original