Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
	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()
Ejemplo n.º 3
0
    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})
Ejemplo n.º 4
0
    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()
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
    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()
Ejemplo n.º 7
0
    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)
Ejemplo n.º 8
0
    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
Ejemplo n.º 9
0
    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
Ejemplo n.º 10
0
    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)
Ejemplo n.º 11
0
    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)
Ejemplo n.º 12
0
    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')
Ejemplo n.º 13
0
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
Ejemplo n.º 14
0
	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')
Ejemplo n.º 15
0
    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'
Ejemplo n.º 16
0
    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()
Ejemplo n.º 17
0
	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()
Ejemplo n.º 18
0
    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)
Ejemplo n.º 19
0
    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()
Ejemplo n.º 20
0
    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()
Ejemplo n.º 21
0
    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
Ejemplo n.º 22
0
    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
Ejemplo n.º 23
0
	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)
Ejemplo n.º 24
0
    def writeData(self, path, data):

        if not os.path.exists(os.path.dirname(path)):
            os.makedirs(os.path.dirname(path))

        fileUtils.ymlDumper(path, data)
Ejemplo n.º 25
0
 def clearList(self):
     data = {'commands': []}
     fileUtils.ymlDumper(self.dataPath, data)
     self.listExeList()
Ejemplo n.º 26
0
    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')
Ejemplo n.º 27
0
	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')
Ejemplo n.º 28
0
    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()
Ejemplo n.º 29
0
 def clearList(self) : 
     data = {'commands': []}
     fileUtils.ymlDumper(self.dataPath, data)
     self.listExeList()
Ejemplo n.º 30
0
	def writeData(self, path, data) : 

		if not os.path.exists(os.path.dirname(path)) : 
			os.makedirs(os.path.dirname(path)) 

		fileUtils.ymlDumper(path, data)