<commit_before>'''
####################################################################################
####################################################################################
## SCRIPT HEADER ##
# Created By             : <NAME>
# Email                      : <EMAIL>
# Start Date               : 12 May, 2017

# Purpose: create menubar in maya
# Bugs: 
# History: 
# Note: 
####################################################################################
####################################################################################
'''
import os
import pymel.core.uitypes as pmui
import pymel.core.windows as pywin
import maya.mel as mel
 
class Menubar(pmui.SubMenuItem):
    def __new__(cls, menubarPath, parent = None):
        menubarName = os.path.basename( menubarPath )
        menuId = cls.getMenuId( menubarName.replace( "_", " " ) )
        
        if pywin.menu( menuId, ex = 1 ):
            pywin.deleteUI(menuId)
            
        self = pywin.menu( menuId, l = menuId, aob = 1, tearOff = 1, p = parent )
        return pmui.SubMenuItem.__new__(cls, self)
    
    @staticmethod
    def getMenuId(name):
        menuName = ""
        for char in name:
            if char.isalpha() or char.isdigit() or char.isspace():
                menuName += char
        return menuName
 
    def __init__(self, menubarPath, name=None, parent=None):
        self.menubarPath = menubarPath
        
        self.buildSubMenu( self )
    
    def buildSubMenu(self, parent):
        # get all subfolder
        subfolder = os.listdir( parent.menubarPath )
        
        for o in subfolder:
#             Menubar( os.path.join( parent.menubarPath, o ), parent = self )
            pywin.subMenuItem( label = o, subMenu = 1, p = self, tearOff = 1, postMenuCommandOnce = 1 )

def buildMenubar():
# TODO : - Make it possible to create multiple menubarItem root
# TODO : - Next create .ini which makes different between submenu and toolmenu
    # get menubar item
    menubarItemPath = os.path.join( os.path.dirname(__file__), 'menubarItem' )
    rootMenubarPath = os.path.join( menubarItemPath, os.listdir( menubarItemPath )[0] )
    # get maya main window
    mainWindow = mel.eval( "$temp=$gMainWindow" )
    
    # try build the menu
    Menubar( rootMenubarPath, parent = mainWindow )
    
    print "Fucking Asshole"<commit_msg>Create multiple menubarItem root from 'menubarItem\*'<commit_after>'''
####################################################################################
####################################################################################
## SCRIPT HEADER ##
# Created By             : <NAME>
# Email                      : <EMAIL>
# Start Date               : 12 May, 2017

# Purpose: create menubar in maya
# Bugs: 
# History: 
# Note: 
####################################################################################
####################################################################################
'''
import os
import pymel.core.uitypes as pmui
import pymel.core.windows as pywin
import maya.mel as mel
 
class Menubar(pmui.SubMenuItem):
    def __new__(cls, menubarPath, parent = None):
        # give menubar proper name which is basename instead fullpath name
        menubarName = os.path.basename( menubarPath )
        menuId = cls.getMenuId( menubarName.replace( "_", " " ) )
        
        # delete existing menu if the menu already exist
        if pywin.menu( menuId, ex = 1 ):
            pywin.deleteUI(menuId)
            
        self = pywin.menu( menuId, l = menuId, aob = 1, tearOff = 1, p = parent )
        return pmui.SubMenuItem.__new__(cls, self)
    
    @staticmethod
    def getMenuId(name):
        # get menu name and use it for menu identifier
        menuName = ""
        for char in name:
            if char.isalpha() or char.isdigit() or char.isspace():
                menuName += char
        return menuName
 
    def __init__(self, menubarPath, name=None, parent=None):
        self.menubarPath = menubarPath
        
        self.buildSubMenu( self )
    
    def buildSubMenu(self, parent):
        # get all subfolder
        subfolder = os.listdir( parent.menubarPath )
        
        for o in subfolder:
#             Menubar( os.path.join( parent.menubarPath, o ), parent = self )
            pywin.subMenuItem( label = o, subMenu = 1, p = self, tearOff = 1, postMenuCommandOnce = 1 )

def buildMenubar():
# TODO: Next create .ini which makes different between submenu and toolmenu
    # get all menubar root item
    menubarItemPath = os.path.join( os.path.dirname(__file__), 'menubarItem' )
    menubarList = os.listdir( menubarItemPath )
    # get maya main window
    mainWindow = mel.eval( "$temp=$gMainWindow" )
    
    # build all menubar root item
    for o in menubarList:
        Menubar( os.path.join( menubarItemPath, o ), parent = mainWindow )
    
    print "Fucking Asshole"
{'fraction_non_alphanumeric': 0.22177009155645983, 'fraction_numerical': 0.00508646998982706, 'mean_word_length': 2.7873651771956856, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2586704', 'n_tokens_mistral': 1443, 'n_tokens_neox': 1389, 'n_words': 384}