def createNewDirectory(self, *itemList): item = itemList[-1] pubDir = item._metaobj #proj = self.model()._metamodel if not pubDir.allowFreePublish(): confirmDialog(title='SORRY !', message="You can't add new directories here.", button=["OK"], icon="information") return result = promptDialog(title='Please...', message='Directory Name: ', button=['OK', 'Cancel'], defaultButton='OK', cancelButton='Cancel', dismissString='Cancel', scrollableField=True, ) if result == 'Cancel': logMsg("Cancelled !" , warning=True) return sDirName = promptDialog(query=True, text=True) if not sDirName: return os.mkdir(pathJoin(pubDir.absPath(), sDirName.strip().replace(" ", "_"))) pubDir.refresh(children=True)
def createNewAsset(self, *itemList): item = itemList[-1] drcDir = item._metaobj library = drcDir.library if library.sectionName != "asset_lib": raise RuntimeError("Cannot create new asset under '{}'" .format(library.sectionName)) proj = library.project sSection = drcDir.name if not proj._confobj.hasSection(sSection): raise RuntimeError("No such asset type configured: '{}'." .format(sSection)) if not proj._confobj.getVar(sSection, "template_dir", ""): raise RuntimeError("No template configured for '{}'".format(sSection)) result = promptDialog(title='Please...', message='Entity Name: ', button=['OK', 'Cancel'], defaultButton='OK', cancelButton='Cancel', dismissString='Cancel', scrollableField=True, text=sSection + "_" ) if result == 'Cancel': logMsg("Cancelled !" , warning=True) return sEntityName = promptDialog(query=True, text=True) if not sEntityName: return damAst = DamAsset(proj, name=sEntityName, assetType=sSection) if damAst.assetType != sSection: raise ValueError("Bad asset type: '{}' ! Expected '{}'." .format(damAst.assetType, sSection)) damAst.createDirsAndFiles(dryRun=False) astDir = damAst.getResource("public", "entity_dir") if astDir: astDir.parentDir().refresh(children=True) astDir.setSyncRules(astDir.syncRules)
def promptForComment(**kwargs): sComment = "" bOk = False result = promptDialog(title='Please...', message='Leave a comment: ', button=['OK', 'Cancel'], defaultButton='OK', cancelButton='Cancel', dismissString='Cancel', scrollableField=True, **kwargs) if result == 'Cancel': logMsg("Cancelled !" , warning=True) elif result == 'OK': sComment = promptDialog(query=True, text=True) bOk = True return sComment, bOk
def promptForComment(**kwargs): sComment = "" bOk = False result = promptDialog( title="Please...", message="Leave a comment: ", button=["OK", "Cancel"], defaultButton="OK", cancelButton="Cancel", dismissString="Cancel", scrollableField=True, **kwargs ) if result == "Cancel": logMsg("Cancelled !", warning=True) elif result == "OK": sComment = promptDialog(query=True, text=True) bOk = True return sComment, bOk