def buildPublishList(cls, inline, *args, **kwargs): ''' build a list of the scripts that are published and some relevent commands ''' moduleBase = 'lct.src' data = [] srcPath = path.getSrcPath() for subDir in os.listdir(srcPath): full = os.path.normpath(os.path.join(srcPath, subDir)) if os.path.isdir(full): if os.path.exists(os.path.normpath(os.path.normpath(os.path.join(full, subDir+'.py'))) ): file = open(os.path.normpath(os.path.join(full, subDir+'.py')) ) first = file.readline()[:-2]# ???? if first.split(' = ')[0] == 'publish': publish = first.split(' = ')[1] annotation = file.readline()[:-2].split(' = ')[1].split('"')[1] prefix = file.readline()[:-2].split(' = ')[1].split("'")[1] if inline: #if you need to preserve the command as a single line when printing or writing to a file runCommand = 'import '+moduleBase+'.'+subDir+'.'+subDir+' as '+prefix+'\\nreload('+prefix+')\\n'+prefix+'.'+subDir+'UI()' else: runCommand = 'import '+moduleBase+'.'+subDir+'.'+subDir+' as '+prefix+'\nreload('+prefix+')\n'+prefix+'.'+subDir+'UI()' set = [subDir, prefix, annotation, publish, runCommand] #print 'set: {0}'.format(set) data.append(set) return data
def makeLctShelf(cls, *args, **kwargs): """ """ src = path.getSrcPath() mel = path.getMelPath() shelf = os.path.normpath(os.path.join(mel, 'shelf_LCT.mel')) file = open(shelf, 'w+') opening = 'global proc shelf_LCT () {\n global string $gBuffStr;\n global string $gBuffStr0;\n global string $gBuffStr1;\n\n' closing = '\n}' file.write(opening) initShelfIcon = os.path.normpath( os.path.join(src, 'icons', 'shelf.png')) initShelfLabel = 'Init Shelf' initShelfAnno = 'Initialize LCT Shelf' initShelfCommand = 'from lct.src.core.lcShelf import Shelf as shelf\nshelf.makeLctShelf()' file.write(closing) file.close() if not pm.layout('LCT', ex=True): if os.name == 'nt': shelf = shelf.replace('\\', '/') pm.mel.loadNewShelf(shelf) pm.shelfButton(label=initShelfLabel, annotation=initShelfAnno, image1=initShelfIcon, command=initShelfCommand) else: pm.mel.eval( 'shelfTabLayout -edit -selectTab "LCT" $gShelfTopLevel;') list = utility.buildPublishList(inline=False) for item in list: if item[3] == 'True': label = item[0] annotation = item[2] icon = os.path.normpath( os.path.join(src, label, item[0] + '.png')) runCommand = item[4] cls.makeShelfButton(label, runCommand, icon, annotation)
def makeLctShelf(cls, *args, **kwargs): """ """ src = path.getSrcPath() mel = path.getMelPath() shelf = os.path.normpath(os.path.join(mel, 'shelf_LCT.mel')) file = open(shelf, 'w+') opening = 'global proc shelf_LCT () {\n global string $gBuffStr;\n global string $gBuffStr0;\n global string $gBuffStr1;\n\n' closing = '\n}' file.write(opening) initShelfIcon = os.path.normpath(os.path.join(src, 'icons', 'shelf.png')) initShelfLabel = 'Init Shelf' initShelfAnno = 'Initialize LCT Shelf' initShelfCommand = 'from lct.src.core.lcShelf import Shelf as shelf\nshelf.makeLctShelf()' file.write(closing) file.close() if not pm.layout('LCT', ex=True): if os.name == 'nt': shelf = shelf.replace('\\','/') pm.mel.loadNewShelf(shelf) pm.shelfButton(label=initShelfLabel, annotation=initShelfAnno, image1=initShelfIcon, command=initShelfCommand) else: pm.mel.eval('shelfTabLayout -edit -selectTab "LCT" $gShelfTopLevel;') list = utility.buildPublishList(inline=False) for item in list: if item[3] == 'True': label = item[0] annotation = item[2] icon = os.path.normpath(os.path.join(src, label, item[0]+'.png')) runCommand = item[4] cls.makeShelfButton(label, runCommand, icon, annotation)