<s> """<STR_LIT>""" <EOL> from pymel . all import * <EOL> from pymel . util import * <EOL> from re import search <EOL> from shutil import copyfile <EOL> import datetime <EOL> import fnmatch <EOL> import getpass <EOL> import os <EOL> import sys <EOL> import xml . etree . ElementTree as ET <EOL> class MayaMenu ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> """<STR_LIT>""" <EOL> super ( MayaMenu , self ) . __init__ ( ) <EOL> self . userName = getpass . getuser ( ) <EOL> self . PCStoolsLocation = gv . toolsLocation <EOL> self . PCSlogLocation = gv . logLocation <EOL> self . pcsXML = ET . parse ( '<STR_LIT>' % gv . toolsLocation ) <EOL> self . pcsXMLcore = self . pcsXML . getiterator ( '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> self . log = None <EOL> self . PCSMenu = None <EOL> self . menuDict = { } <EOL> self . PCSDevelopers = eval ( self . pcsXMLcore . get ( '<STR_LIT>' ) ) <EOL> self . PCStoolName = self . pcsXMLcore . get ( '<STR_LIT>' ) <EOL> self . PCStPad = '<STR_LIT>' <EOL> self . PCSmenuPath = '<STR_LIT>' % self . PCStoolsLocation <EOL> self . PCSmenuStart = '<STR_LIT>' % self . PCSmenuPath <EOL> self . runTimeAnnotation = '<STR_LIT>' % self . PCStoolName <EOL> self . menuName = '<STR_LIT>' % self . PCStoolName . replace ( '<STR_LIT:U+0020>' , '<STR_LIT:_>' ) <EOL> self . PCSmVersion = None <EOL> def setGlobalVars ( self ) : <EOL> """<STR_LIT>""" <EOL> if search ( '<STR_LIT>' , about ( version = <NUM_LIT:1> ) ) : <EOL> self . PCSmVersion = float ( about ( version = <NUM_LIT:1> ) . split ( '<STR_LIT:U+0020>' ) [ <NUM_LIT:0> ] ) <EOL> else : <EOL> self . PCSmVersion = float ( about ( version = <NUM_LIT:1> ) ) <EOL> melGlobals . initVar ( '<STR_LIT:float>' , '<STR_LIT>' ) <EOL> melGlobals [ '<STR_LIT>' ] = self . PCSmVersion <EOL> melGlobals . initVar ( '<STR_LIT:string>' , '<STR_LIT>' ) <EOL> melGlobals [ '<STR_LIT>' ] = '<STR_LIT>' % self . PCSmenuPath <EOL> melGlobals . initVar ( '<STR_LIT:string>' , '<STR_LIT>' ) <EOL> melGlobals [ '<STR_LIT>' ] = self . PCStoolName <EOL> melGlobals . initVar ( '<STR_LIT:string>' , '<STR_LIT>' ) <EOL> melGlobals [ '<STR_LIT>' ] = about ( os = True ) <EOL> def setLogger ( self , logInit = <NUM_LIT:0> ) : <EOL> self . log = logger <EOL> self . log . setLevel ( <NUM_LIT:10> ) <EOL> if logInit : <EOL> self . log . debug ( '<STR_LIT>' % self . PCStoolsLocation ) <EOL> self . log . debug ( '<STR_LIT>' % self . PCSDevelopers ) <EOL> self . log . debug ( '<STR_LIT>' % self . PCStoolName ) <EOL> self . log . debug ( '<STR_LIT>' % self . PCSmenuPath ) <EOL> fileLocation = os . path . dirname ( inspect . getsourcefile ( tempFunc ) ) <EOL> self . log . debug ( "<STR_LIT>" % fileLocation ) <EOL> def injectPaths ( self ) : <EOL> """<STR_LIT>""" <EOL> sys . path . append ( '<STR_LIT>' % self . PCStoolsLocation ) <EOL> mVer = about ( version = <NUM_LIT:1> ) <EOL> if about ( win64 = <NUM_LIT:1> ) : <EOL> mVer = mVer . split ( '<STR_LIT:U+0020>' ) [ <NUM_LIT:0> ] <EOL> putEnv ( "<STR_LIT>" , [ getEnv ( '<STR_LIT>' ) , '<STR_LIT>' % ( self . PCSmenuPath , mVer ) , <EOL> '<STR_LIT>' % ( self . PCSmenuPath , mVer ) ] ) <EOL> else : <EOL> putEnv ( "<STR_LIT>" , [ getEnv ( '<STR_LIT>' ) , '<STR_LIT>' % ( self . PCSmenuPath , mVer ) , <EOL> '<STR_LIT>' % ( self . PCSmenuPath , mVer ) ] ) <EOL> def startUp ( self ) : <EOL> """<STR_LIT>""" <EOL> self . setLogger ( <NUM_LIT:1> ) <EOL> self . setGlobalVars ( ) <EOL> self . log . debug ( '<STR_LIT>' ) <EOL> self . PCSMenu_build ( ) <EOL> self . log . debug ( '<STR_LIT>' ) <EOL> self . PCSMenu_envPrinter ( ) <EOL> self . log . debug ( '<STR_LIT>' ) <EOL> self . PCSMenu_localFileCopy ( ) <EOL> self . log . debug ( '<STR_LIT>' ) <EOL> self . PCSMenu_metrics ( ) <EOL> self . log . debug ( '<STR_LIT>' ) <EOL> self . PCSMenu_loggerMenuInit ( ) <EOL> self . log . debug ( '<STR_LIT>' ) <EOL> self . PCSMenu_xPrefsInit ( ) <EOL> self . log . debug ( '<STR_LIT>' ) <EOL> @ staticmethod <EOL> def PCSMenu_xPrefsInit ( ) : <EOL> """<STR_LIT>""" <EOL> if os . path . exists ( '<STR_LIT>' % ( <EOL> internalVar ( userScriptDir = True ) , '<STR_LIT>' ) ) : <EOL> mel . eval ( '<STR_LIT>' % ( <EOL> internalVar ( userScriptDir = True ) , '<STR_LIT>' ) ) <EOL> scriptJob ( event = ( '<STR_LIT>' , "<STR_LIT>" ) ) <EOL> scriptJob ( event = ( '<STR_LIT>' , "<STR_LIT>" ) ) <EOL> @ staticmethod <EOL> def PCSMenu_loggerMenuInit ( ) : <EOL> """<STR_LIT>""" <EOL> loggingControl . initMenu ( ) <EOL> def PCSMenu_metrics ( self ) : <EOL> """<STR_LIT>""" <EOL> writeArr = [ ] <EOL> writeArr . append ( '<STR_LIT>' % datetime . datetime . now ( ) . strftime ( "<STR_LIT>" ) ) <EOL> writeArr . append ( '<STR_LIT>' % self . PCStoolsLocation ) <EOL> writeArr . append ( '<STR_LIT>' % about ( osv = True ) ) <EOL> writeArr . append ( '<STR_LIT>' % about ( v = True ) ) <EOL> _file = open ( '<STR_LIT>' % ( self . PCSlogLocation , self . userName , self . userName ) , "<STR_LIT:w>" ) <EOL> for l in writeArr : <EOL> l = l . strip ( ) <EOL> _file . write ( '<STR_LIT>' % l ) <EOL> _file . close ( ) <EOL> def PCSMenu_localFileCopy ( self ) : <EOL> """<STR_LIT>""" <EOL> usrSetupFile = pcsPath . Path ( '<STR_LIT>' % ( internalVar ( userScriptDir = True ) , '<STR_LIT>' ) ) <EOL> mayaEnvFile = pcsPath . Path ( about ( environmentFile = True ) ) <EOL> if usrSetupFile . exists ( ) : <EOL> targetPath = '<STR_LIT>' % ( <EOL> self . PCSlogLocation , self . userName , usrSetupFile . namebase , usrSetupFile . ext ) <EOL> copyfile ( usrSetupFile , targetPath ) <EOL> if mayaEnvFile . exists ( ) : <EOL> targetPath = '<STR_LIT>' % ( <EOL> self . PCSlogLocation , self . userName , mayaEnvFile . namebase , mayaEnvFile . ext ) <EOL> copyfile ( mayaEnvFile , targetPath ) <EOL> def PCSMenu_envPrinter ( self ) : <EOL> """<STR_LIT>""" <EOL> _file = open ( '<STR_LIT>' % ( self . PCSlogLocation , self . userName , self . userName ) , "<STR_LIT:w>" ) <EOL> for l in mayaCore . Maya ( ) . getEnv ( <NUM_LIT:0> ) : <EOL> _file . write ( l ) <EOL> _file . close ( ) <EOL> def PCSMenu_cleanRunTimeCommands ( self ) : <EOL> """<STR_LIT>""" <EOL> searchPadding = self . PCStPad <EOL> for rTimeC in runTimeCommand ( q = <NUM_LIT:1> , userCommandArray = <NUM_LIT:1> ) : <EOL> if len ( rTimeC . split ( '<STR_LIT:_>' ) ) > <NUM_LIT:1> : <EOL> if rTimeC . split ( '<STR_LIT:_>' ) [ <NUM_LIT:0> ] == searchPadding : <EOL> runTimeCommand ( rTimeC , e = <NUM_LIT:1> , delete = <NUM_LIT:1> ) <EOL> def PCSMenu_build ( self ) : <EOL> """<STR_LIT>""" <EOL> if not cmds . menuItem ( self . menuName , q = <NUM_LIT:1> , ex = <NUM_LIT:1> ) : <EOL> self . PCSMenu = Menu ( self . menuName , parent = melGlobals [ '<STR_LIT>' ] , allowOptionBoxes = <NUM_LIT:1> , tearOff = <NUM_LIT:1> , <EOL> label = self . PCStoolName ) <EOL> else : <EOL> self . PCSMenu = Menu ( self . menuName ) <EOL> with self . PCSMenu : <EOL> with subMenuItem ( '<STR_LIT>' , label = "<STR_LIT>" , tearOff = <NUM_LIT:1> , allowOptionBoxes = <NUM_LIT:1> ) : <EOL> menuItem ( label = '<STR_LIT>' , command = self . PCSMenu_refresh ) <EOL> mel . eval ( '<STR_LIT>' % self . PCSmenuPath ) <EOL> mel . eval ( '<STR_LIT>' % self . PCSmenuPath ) <EOL> menuItem ( divider = <NUM_LIT:1> ) <EOL> with subMenuItem ( label = "<STR_LIT>" , tearOff = <NUM_LIT:1> , allowOptionBoxes = <NUM_LIT:1> ) : <EOL> menuItem ( label = '<STR_LIT>' ) <EOL> menuItem ( divider = <NUM_LIT:1> ) <EOL> for root , unused , unused in os . walk ( os . path . abspath ( self . PCSmenuStart ) ) : <EOL> if not pcsPath . Path ( root ) . makePretty ( <NUM_LIT:0> , <NUM_LIT:0> ) == self . PCSmenuStart : <EOL> mFiles = [ ] <EOL> for fname in os . listdir ( root ) : <EOL> fullPath = '<STR_LIT>' % ( root , fname ) <EOL> if pcsPath . Path ( fullPath ) . isfile ( ) and ( <EOL> fnmatch . fnmatch ( fname , '<STR_LIT>' ) or fnmatch . fnmatch ( fname , '<STR_LIT>' ) ) : <EOL> mFiles . append ( fname ) <EOL> self . menuDict [ pcsPath . Path ( root ) . makePretty ( <NUM_LIT:0> , <NUM_LIT:0> ) ] = mFiles <EOL> sKeys = [ ] <EOL> for dr in self . menuDict . iterkeys ( ) : <EOL> sKeys . append ( dr ) <EOL> sKeys . sort ( ) <EOL> for s in sKeys : <EOL> dictFiles = self . menuDict [ s ] <EOL> dictFiles . sort ( ) <EOL> cMainName = s . replace ( self . PCSmenuStart , self . PCStPad ) . replace ( '<STR_LIT:/>' , '<STR_LIT:_>' ) . replace ( '<STR_LIT:\\>' , '<STR_LIT:_>' ) <EOL> if len ( s . namebase . split ( '<STR_LIT:_>' ) ) > <NUM_LIT:1> : <EOL> cMainLabel = s . namebase . split ( '<STR_LIT:_>' ) [ len ( s . namebase . split ( '<STR_LIT:_>' ) ) - <NUM_LIT:1> ] <EOL> else : <EOL> cMainLabel = s . namebase <EOL> cMainParent = s . dirname ( ) <EOL> if cMainParent == self . PCSmenuStart : <EOL> cMainParent = self . PCSMenu <EOL> else : <EOL> cMainParent = cMainParent . replace ( self . PCSmenuStart , self . PCStPad ) . replace ( '<STR_LIT:/>' , '<STR_LIT:_>' ) <EOL> if re . search ( '<STR_LIT>' , str ( s ) ) : <EOL> cmds . menuItem ( p = cMainParent , divider = <NUM_LIT:1> ) <EOL> else : <EOL> with subMenuItem ( cMainName , label = cMainLabel , tearOff = <NUM_LIT:1> , allowOptionBoxes = <NUM_LIT:1> ) : <EOL> if dictFiles : <EOL> for dFile in dictFiles : <EOL> if re . search ( '<STR_LIT>' , dFile ) : <EOL> menuItem ( divider = <NUM_LIT:1> ) <EOL> else : <EOL> fName = dFile . split ( '<STR_LIT:.>' ) [ <NUM_LIT:0> ] <EOL> sPath = '<STR_LIT>' % ( s , fName ) <EOL> rtCommand = "<STR_LIT>" % ( sPath , fName ) <EOL> rtName = '<STR_LIT>' % ( self . PCStPad , fName ) <EOL> if not runTimeCommand ( rtName , q = <NUM_LIT:1> , ex = <NUM_LIT:1> ) : <EOL> runTimeCommand ( rtName , commandLanguage = "<STR_LIT>" , annotation = self . runTimeAnnotation , <EOL> category = self . PCStoolName , command = rtCommand ) <EOL> runTimeCommand ( edit = <NUM_LIT:1> , category = self . PCStoolName , save = <NUM_LIT:1> ) <EOL> else : <EOL> existingRTCommand = runTimeCommand ( rtName , q = <NUM_LIT:1> , command = <NUM_LIT:1> ) <EOL> if not existingRTCommand == rtCommand : <EOL> runTimeCommand ( rtName , e = <NUM_LIT:1> , command = rtCommand ) <EOL> runTimeCommand ( edit = <NUM_LIT:1> , category = self . PCStoolName , save = <NUM_LIT:1> ) <EOL> icon = '<STR_LIT>' <EOL> if os . path . exists ( '<STR_LIT>' % sPath ) : <EOL> icon = '<STR_LIT>' % sPath <EOL> if os . path . exists ( '<STR_LIT>' % sPath ) : <EOL> icon = '<STR_LIT>' % sPath <EOL> if icon : <EOL> menuItem ( label = fName , command = '<STR_LIT>' % rtName , <EOL> image = icon ) <EOL> else : <EOL> menuItem ( label = fName , command = '<STR_LIT>' % rtName ) <EOL> if fName == '<STR_LIT>' : <EOL> mel . eval ( '<STR_LIT>' % self . PCSmenuPath ) <EOL> menuItem ( optionBox = <NUM_LIT:1> , <EOL> command = '<STR_LIT>' ) <EOL> else : <EOL> if os . path . exists ( '<STR_LIT>' % sPath ) : <EOL> mel . eval ( '<STR_LIT>' % self . PCSmenuPath ) <EOL> mel . eval ( '<STR_LIT>' % self . PCSmenuPath ) <EOL> menuItem ( optionBox = <NUM_LIT:1> , <EOL> command = '<STR_LIT>' % ( <EOL> sPath , fName ) ) <EOL> menuItem ( divider = <NUM_LIT:1> ) <EOL> def PCSMenu_refresh ( self , * unused ) : <EOL> """<STR_LIT>""" <EOL> self . log . info ( '<STR_LIT>' ) <EOL> self . PCSMenu . deleteAllItems ( ) <EOL> self . PCSMenu . delete ( ) <EOL> self . PCSMenu_cleanRunTimeCommands ( ) <EOL> self . PCSMenu_build ( ) <EOL> self . log . info ( '<STR_LIT>' ) <EOL> def tempFunc ( ) : <EOL> pass <EOL> if __name__ == '<STR_LIT>' : <EOL> print '<STR_LIT>' <EOL> else : <EOL> from common . core import globalVariables as gv <EOL> MayaMenu ( ) . injectPaths ( ) <EOL> from common . fileIO import pcsPath <EOL> from pymel . tools import loggingControl <EOL> from common . diagnostic . pcsLogger import logger <EOL> import mayaCore <EOL> print "<STR_LIT>" </s>
