def loadFile(self): asset_file = unicode(QtGui.QFileDialog.getOpenFileName()) if not asset_file: return False folder = os.path.dirname(asset_file) try: f = open(asset_file, 'r') asset = simplejson.loads(f.read()) f.close() except: return False self.asset_model.beginResetModel() asset_item = AssetItem() for k in asset.keys(): asset_item.setAttribute(k, asset.get(k, '')) asset_item.setAttribute('path', folder) a = hasset.asset(str(asset['name'])) if a: asset_item.setStatus('name', True) if a.hasGeo(): asset_item.setStatus('geo', True) if a.hasMdd(): asset_item.setStatus('mdd', True) self.asset_model.addAsset(asset_item) self.asset_model.endResetModel() self.asset_list_widget.resizeColumnsToContents() return True
def load(self): folder = str(QtGui.QFileDialog.getExistingDirectory()) if not folder: return False self.asset_model.beginResetModel() asset_files = glob.glob(os.path.join(folder, '*.asset')) for a_file in asset_files: try: f = open(a_file, 'r') asset = simplejson.loads(f.read()) f.close() except: continue asset_item = AssetItem() for k in asset.keys(): asset_item.setAttribute(k, asset.get(k, '')) asset_item.setAttribute('path', folder) a = hasset.asset(str(asset['name'])) if a: asset_item.setStatus('name', True) if a.hasGeo(): asset_item.setStatus('geo', True) if a.hasMdd(): asset_item.setStatus('mdd', True) self.asset_model.addAsset(asset_item) self.asset_model.endResetModel() self.asset_list_widget.resizeColumnsToContents() return True
def split(self): rows = self.selectedAssetsRow() for row in rows: asset = self.asset_model.assetItem(row) name = str(asset.getAttribute('name')) a = hasset.asset(name) if a: a.split() return True
def addGeo(self): rows = self.selectedAssetsRow() self.asset_model.beginResetModel() for row in rows: asset = self.asset_model.assetItem(row) name = str(asset.getAttribute('name')) a = hasset.asset(name) if a: folder = asset.getAttribute('path') geo = asset.getAttribute('geo') geo_file = os.path.join(folder, geo) a.addGeo(str(geo_file.replace("\\", "/"))) self.asset_model.editAssetStatus(row, 'geo', True) self.asset_model.endResetModel() return True
def addMdd(self): rows = self.selectedAssetsRow() self.asset_model.beginResetModel() for row in rows: asset = self.asset_model.assetItem(row) name = str(asset.getAttribute('name')) a = hasset.asset(name) if a: folder = asset.getAttribute('path') mdd = asset.getAttribute('mdd') start_frame = string.atoi(asset.getAttribute('start_frame')) mdd_file = os.path.join(folder, mdd) a.addMDD(str(mdd_file.replace("\\", "/")), start_frame) self.asset_model.editAssetStatus(row, 'mdd', True) self.asset_model.endResetModel() return True
def delete(self): rows = self.selectedAssetsRow() self.asset_model.beginResetModel() for row in rows: asset = self.asset_model.assetItem(row) name = str(asset.getAttribute('name')) h_asset = hasset.asset(name) if h_asset: h_asset.destroy() self.asset_model.editAssetStatus(row, 'name', False) if str(asset.getAttribute('geo')): self.asset_model.editAssetStatus(row, 'geo', False) if str(asset.getAttribute('mdd')): self.asset_model.editAssetStatus(row, 'mdd', False) self.asset_model.endResetModel() return True