def removeNonCache(self): nonCacheFile = self.getCachePathInfo(True)['nonCacheDataPath'] listWidget = 'nonCache_listWidget' items = self.getSelectedItems(listWidget) # remove from file if items: if os.path.exists(nonCacheFile): data = fileUtils.ymlLoader(nonCacheFile) for each in items: grp = each[0] if 'nonCache' in data.keys(): if grp in data['nonCache']: data['nonCache'].remove(grp) else: data = {'nonCache': selItems} fileUtils.ymlDumper(nonCacheFile, data) self.refreshUI()
def removeNonCache(self) : nonCacheFile = self.getCachePathInfo(True)['nonCacheDataPath'] listWidget = 'nonCache_listWidget' items = self.getSelectedItems(listWidget) # remove from file if items : if os.path.exists(nonCacheFile) : data = fileUtils.ymlLoader(nonCacheFile) for each in items : grp = each[0] if 'nonCache' in data.keys() : if grp in data['nonCache'] : data['nonCache'].remove(grp) else : data = {'nonCache': selItems} fileUtils.ymlDumper(nonCacheFile, data) self.refreshUI()
def save_cache(self, objs): dataFile = self.data_file() dataPath = os.path.dirname(dataFile) if not os.path.exists(dataPath): os.makedirs(dataPath) fileUtils.ymlDumper(dataFile, {'objects': objs})
def doRemoveList(self) : if self.ui.exe_listWidget.currentItem() : row = self.ui.exe_listWidget.currentRow() data = self.readDataPath() if data : del data['commands'][row] fileUtils.ymlDumper(self.dataPath, data) self.listExeList()
def savePresetToDefault(self): # get data dataUI = self.getAllExeList() # change preset back to default self.ui.preset_comboBox.setCurrentIndex(0) # add to txt data = {'commands': dataUI} fileUtils.ymlDumper(self.dataPath, data)
def doRemoveList(self): if self.ui.exe_listWidget.currentItem(): row = self.ui.exe_listWidget.currentRow() data = self.readDataPath() if data: del data['commands'][row] fileUtils.ymlDumper(self.dataPath, data) self.listExeList()
def savePresetToDefault(self) : # get data dataUI = self.getAllExeList() # change preset back to default self.ui.preset_comboBox.setCurrentIndex(0) # add to txt data = {'commands': dataUI} fileUtils.ymlDumper(self.dataPath, data)
def readPreset(self) : data = None if not os.path.exists(self.presetPath) : data = {'Default': [], 'Examples': ['clean']} fileUtils.checkDir(self.presetPath) fileUtils.ymlDumper(self.presetPath, data) else : data = fileUtils.ymlLoader(self.presetPath) return data
def readPreset(self): data = None if not os.path.exists(self.presetPath): data = {'Default': [], 'Examples': ['clean']} fileUtils.checkDir(self.presetPath) fileUtils.ymlDumper(self.presetPath, data) else: data = fileUtils.ymlLoader(self.presetPath) return data
def doSavePreset(self) : cmds = self.getAllExeList() name = str(self.ui.preset_lineEdit.text()) presetData = self.readPreset() if not name in presetData.keys() : presetData.update({name: cmds}) fileUtils.ymlDumper(self.presetPath, presetData) self.setOutputLog('Saved preset %s complete.' % name) self.setPresetComboBox() else : self.setOutputLog('Name %s exists' % name)
def doSavePreset(self): cmds = self.getAllExeList() name = str(self.ui.preset_lineEdit.text()) presetData = self.readPreset() if not name in presetData.keys(): presetData.update({name: cmds}) fileUtils.ymlDumper(self.presetPath, presetData) self.setOutputLog('Saved preset %s complete.' % name) self.setPresetComboBox() else: self.setOutputLog('Name %s exists' % name)
def doExportNonCache(self): nonCacheData = dict() nonCachePath = self.getCachePathInfo(True)['nonCachePath'] nonCacheDataPath = self.getCachePathInfo(True)['nonCacheDataPath'] listWidget = 'nonCache_listWidget' if self.ui.exportAll_checkBox.isChecked(): items = self.getAllItems(listWidget) else: items = self.getSelectedItems(listWidget) if not os.path.exists(nonCachePath): os.makedirs(nonCachePath) if items: for i in range(len(items[0])): text1 = items[0][i] text2 = items[1][i] itemWidget = items[2][i] exportGrp = text2 fileName = text1 # if text2 is self.nonCacheAsset, use text1 as an exportGrp if text2 == self.nonCacheAsset: exportGrp = text1 fileName = text1.replace(':', '') exportFile = '%s/%s.ma' % (nonCachePath, fileName) result = hook.export(exportGrp, exportFile) itemWidget.setIcon(self.okIcon, self.iconSize) # data nonCacheData.update({ str(fileName): { 'exportGrp': str(exportGrp), 'filePath': str(exportFile) } }) logger.debug(result) QtGui.QApplication.processEvents() # write data fileUtils.ymlDumper(nonCacheDataPath, nonCacheData) logger.debug('Write noncache data successfully')
def exportData(*arg): path = mc.file(q=True, sn=True) sceneName = path.split('/')[-1].split('_v')[0] cachePath = path.split('scenes/')[0] + 'cache/' transform = dict() sets = dict() setNames = mc.ls(sl=True) for sel in mc.listRelatives(setNames[0], c=True): transform[sel] = {'s': list(mc.getAttr('%s.s' % (sel))[0])} scalePath = cachePath + '_assemblyScale.yml' fileUtils.ymlDumper(scalePath, transform) print 'Save as ' + scalePath
def doExportNonCache(self) : nonCacheData = dict() nonCachePath = self.getCachePathInfo(True)['nonCachePath'] nonCacheDataPath = self.getCachePathInfo(True)['nonCacheDataPath'] listWidget = 'nonCache_listWidget' if self.ui.exportAll_checkBox.isChecked() : items = self.getAllItems(listWidget) else : items = self.getSelectedItems(listWidget) if not os.path.exists(nonCachePath) : os.makedirs(nonCachePath) if items : for i in range(len(items[0])) : text1 = items[0][i] text2 = items[1][i] itemWidget = items[2][i] exportGrp = text2 fileName = text1 # if text2 is self.nonCacheAsset, use text1 as an exportGrp if text2 == self.nonCacheAsset : exportGrp = text1 fileName = text1.replace(':', '') exportFile = '%s/%s.ma' % (nonCachePath, fileName) result = hook.export(exportGrp, exportFile) itemWidget.setIcon(self.okIcon, self.iconSize) # data nonCacheData.update({str(fileName): {'exportGrp': str(exportGrp), 'filePath': str(exportFile)}}) logger.debug(result) QtGui.QApplication.processEvents() # write data fileUtils.ymlDumper(nonCacheDataPath, nonCacheData) logger.debug('Write noncache data successfully')
def saveList(self) : if self.ui.autoSave_checkBox.isChecked() : dirname = os.path.dirname(self.listFile) if not os.path.exists(dirname) : os.makedirs(dirname) result = fileUtils.ymlDumper(self.listFile, self.data) print 'Save list'
def addNonCache(self): # add to file nonCacheFile = self.getCachePathInfo(True)['nonCacheDataPath'] selItems = hook.getSelectedObjs() if selItems: self.writeStatus() if os.path.exists(nonCacheFile): data = fileUtils.ymlLoader(nonCacheFile) for each in selItems: if 'nonCache' in data.keys(): if not each in data['nonCache']: data['nonCache'].append(each) else: data = {'nonCache': selItems} fileUtils.ymlDumper(nonCacheFile, data) self.refreshUI()
def addNonCache(self) : # add to file nonCacheFile = self.getCachePathInfo(True)['nonCacheDataPath'] selItems = hook.getSelectedObjs() if selItems : self.writeStatus() if os.path.exists(nonCacheFile) : data = fileUtils.ymlLoader(nonCacheFile) for each in selItems : if 'nonCache' in data.keys() : if not each in data['nonCache'] : data['nonCache'].append(each) else : data = {'nonCache': selItems} fileUtils.ymlDumper(nonCacheFile, data) self.refreshUI()
def writeStatus(self): logger.debug('start record status ...') dataPath = self.getCachePathInfo(True)['dataPath'] statusInfo = dict() if not os.path.exists(os.path.dirname(dataPath)): os.makedirs(os.path.dirname(dataPath)) if os.path.exists(dataPath): statusInfo = fileUtils.ymlLoader(dataPath) cacheListWidget = 'cache_listWidget' cacheTexts = self.getAllItems(cacheListWidget) cacheText1 = cacheTexts[0] cacheText2 = cacheTexts[1] if cacheText1 and cacheText2: for i in range(len(cacheText1)): namespace = cacheText1[i] rigGrp = cacheText2[i] statusInfo.update({ rigGrp: { 'namespace': namespace, 'status': 'cache', 'rigGrp': rigGrp } }) nonCacheListWidget = 'nonCache_listWidget' nonCacheTexts = self.getAllItems(nonCacheListWidget) nonCacheText1 = nonCacheTexts[0] nonCacheText2 = nonCacheTexts[1] if nonCacheText1 and nonCacheText2: for i in range(len(nonCacheText1)): namespace = nonCacheText1[i] rigGrp = nonCacheText2[i] statusInfo.update({ rigGrp: { 'namespace': namespace, 'status': 'nonCache', 'rigGrp': rigGrp } }) result = fileUtils.ymlDumper(dataPath, statusInfo) logger.debug('write status info %s' % dataPath)
def doAddList(self): sels = self.ui.cmd_listWidget.selectedItems() if sels: items = [str(a.text()) for a in sels] # get data dataUI = self.getAllExeList() # change preset back to default self.ui.preset_comboBox.setCurrentIndex(0) # add to txt data = {'commands': dataUI} fileUtils.ymlDumper(self.dataPath, data) data = self.readDataPath() for each in items: data['commands'].append(each) fileUtils.ymlDumper(self.dataPath, data) self.listExeList()
def doAddList(self) : sels = self.ui.cmd_listWidget.selectedItems() if sels : items = [str(a.text()) for a in sels] # get data dataUI = self.getAllExeList() # change preset back to default self.ui.preset_comboBox.setCurrentIndex(0) # add to txt data = {'commands': dataUI} fileUtils.ymlDumper(self.dataPath, data) data = self.readDataPath() for each in items : data['commands'].append(each) fileUtils.ymlDumper(self.dataPath, data) self.listExeList()
def readDataPath(self) : data = None if os.path.exists(self.dataPath) : data = fileUtils.ymlLoader(self.dataPath) else : data = {'commands': []} if not os.path.exists(os.path.dirname(self.dataPath)) : os.makedirs(os.path.dirname(self.dataPath)) result = fileUtils.ymlDumper(self.dataPath, data) return self.readDataPath() return data
def readDataPath(self): data = None if os.path.exists(self.dataPath): data = fileUtils.ymlLoader(self.dataPath) else: data = {'commands': []} if not os.path.exists(os.path.dirname(self.dataPath)): os.makedirs(os.path.dirname(self.dataPath)) result = fileUtils.ymlDumper(self.dataPath, data) return self.readDataPath() return data
def writeStatus(self) : logger.debug('start record status ...') dataPath = self.getCachePathInfo(True)['dataPath'] statusInfo = dict() if not os.path.exists(os.path.dirname(dataPath)) : os.makedirs(os.path.dirname(dataPath)) if os.path.exists(dataPath) : statusInfo = fileUtils.ymlLoader(dataPath) cacheListWidget = 'cache_listWidget' cacheTexts = self.getAllItems(cacheListWidget) cacheText1 = cacheTexts[0] cacheText2 = cacheTexts[1] if cacheText1 and cacheText2 : for i in range(len(cacheText1)) : namespace = cacheText1[i] rigGrp = cacheText2[i] statusInfo.update({rigGrp: {'namespace': namespace, 'status': 'cache', 'rigGrp': rigGrp}}) nonCacheListWidget = 'nonCache_listWidget' nonCacheTexts = self.getAllItems(nonCacheListWidget) nonCacheText1 = nonCacheTexts[0] nonCacheText2 = nonCacheTexts[1] if nonCacheText1 and nonCacheText2 : for i in range(len(nonCacheText1)) : namespace = nonCacheText1[i] rigGrp = nonCacheText2[i] statusInfo.update({rigGrp: {'namespace': namespace, 'status': 'nonCache', 'rigGrp': rigGrp}}) result = fileUtils.ymlDumper(dataPath, statusInfo) logger.debug('write status info %s' % dataPath)
def writeData(self, path, data): if not os.path.exists(os.path.dirname(path)): os.makedirs(os.path.dirname(path)) fileUtils.ymlDumper(path, data)
def clearList(self): data = {'commands': []} fileUtils.ymlDumper(self.dataPath, data) self.listExeList()
def assignAssetStatus(self, mode): logger.debug('=====================') logger.debug('assignAssetStatus ...') rigGrps = [] addGrps = [] notAddGrps = [] # send to cache if mode == 'cache': logger.debug('cache mode') listWidget = 'nonCache_listWidget' items = self.getSelectedItems(listWidget) logger.debug(items) if items: rigGrps = items[1] # send to non cache if mode == 'nonCache': logger.debug('nonCache mode') listWidget = 'cache_listWidget' items = self.getSelectedItems(listWidget) logger.debug(items) if items: rigGrps = items[1] if rigGrps: self.writeStatus() dataPath = self.getCachePathInfo(True)['dataPath'] if dataPath: data = fileUtils.ymlLoader(dataPath) if data: for each in rigGrps: if each in data.keys(): if not each == self.nonCacheAsset: data[each]['status'] = mode addGrps.append(each) else: notAddGrps.append(each) logger.debug('writing data back') fileUtils.ymlDumper(dataPath, data) # refresh UI self.refreshUI() if addGrps: display = (', ').join(addGrps) logger.info('%s added to %s' % (display, mode)) if notAddGrps: display = (', ').join(notAddGrps) logger.info('%s cannot be added to %s' % (display, mode)) else: logger.warning('no items selected')
def assignAssetStatus(self, mode) : logger.debug('=====================') logger.debug('assignAssetStatus ...') rigGrps = [] addGrps = [] notAddGrps = [] # send to cache if mode == 'cache' : logger.debug('cache mode') listWidget = 'nonCache_listWidget' items = self.getSelectedItems(listWidget) logger.debug(items) if items : rigGrps = items[1] # send to non cache if mode == 'nonCache' : logger.debug('nonCache mode') listWidget = 'cache_listWidget' items = self.getSelectedItems(listWidget) logger.debug(items) if items : rigGrps = items[1] if rigGrps : self.writeStatus() dataPath = self.getCachePathInfo(True)['dataPath'] if dataPath : data = fileUtils.ymlLoader(dataPath) if data : for each in rigGrps : if each in data.keys() : if not each == self.nonCacheAsset : data[each]['status'] = mode addGrps.append(each) else : notAddGrps.append(each) logger.debug('writing data back') fileUtils.ymlDumper(dataPath,data) # refresh UI self.refreshUI() if addGrps : display = (', ').join(addGrps) logger.info('%s added to %s' % (display, mode)) if notAddGrps : display = (', ').join(notAddGrps) logger.info('%s cannot be added to %s' % (display, mode)) else : logger.warning('no items selected')
def copy(self): path = str(self.ui.pathLineEdit.text()) user = str(self.ui.userLineEdit.text()) copylist = fileUtils.listFile(path) verlist = [ int(n.split('_')[-1].split('.')[0]) for n in copylist if n.split('_')[-1].split('.')[0].isdigit() ] verlist.sort() version = verlist[-1] + 1 if not self.ui.overrideCheckBox.isChecked(): logPath = '%s/%s_asm_%03d.db' % (path, user, version) if self.ui.overrideCheckBox.isChecked(): filename = str(self.ui.filenameLineEdit.text()) logPath = '%s/%s.db' % (path, filename) logPath = logPath.replace('\\', '/') # print logPath sel = mc.ls(sl=True, type='assemblyReference') allAR = dict() # print sel for ar in sel: if ':' in ar: arParent = ar.split('_NS')[0] if not allAR.has_key(arParent): path = mc.getAttr('%s.definition' % arParent) t = list(mc.getAttr('%s.t' % arParent)[0]) r = list(mc.getAttr('%s.r' % arParent)[0]) s = list(mc.getAttr('%s.s' % arParent)[0]) allAR[arParent] = { 'definition': path, 't': t, 'r': r, 's': s, 'type': 'parent' } path = mc.getAttr('%s.definition' % ar) t = list(mc.getAttr('%s.t' % ar)[0]) r = list(mc.getAttr('%s.r' % ar)[0]) s = list(mc.getAttr('%s.s' % ar)[0]) if not allAR[arParent].has_key('child'): allAR[arParent]['child'] = dict() allAR[arParent]['child'][ar] = { 'definition': path, 't': t, 'r': r, 's': s } else: path = mc.getAttr('%s.definition' % ar) t = list(mc.getAttr('%s.t' % ar)[0]) r = list(mc.getAttr('%s.r' % ar)[0]) s = list(mc.getAttr('%s.s' % ar)[0]) allAR[ar] = { 'definition': path, 't': t, 'r': r, 's': s, 'type': 'child' } fileUtils.ymlDumper(logPath, allAR) if os.path.exists(logPath): self.listCopy()
def clearList(self) : data = {'commands': []} fileUtils.ymlDumper(self.dataPath, data) self.listExeList()
def writeData(self, path, data) : if not os.path.exists(os.path.dirname(path)) : os.makedirs(os.path.dirname(path)) fileUtils.ymlDumper(path, data)