def clickedDelDesc(): # add current thing to the desc list newItem = self.ui.DescLineEdit.text() # get current list currentDescList = CFL.getFile("DescriptionList") CFL.subFromList(currentDescList, newListItem=newItem, type="DescList") currentDescList = CFL.getFile("DescriptionList") self.ui.DescTextBrowser.setText('\n'.join( str(result) for result in currentDescList))
def clickedAddState(): # add current thing to the desc list newItem = self.ui.StatesLineEdit.text() # get current list currentStateList = CFL.getFile("StateList") CFL.addToList(currentStateList, newListItem=newItem, type="StateList") currentStateList = CFL.getFile("StateList") self.ui.StatesTextBrowser.setText('\n'.join( str(result) for result in currentStateList))
def clickedDeleteDirect(): # add current thing to the directory list newPath = self.ui.directoriesLineEdit.text() newPath = cleanPath(newPath) #print(newPath) currentDirectory = CFL.getFile("Directory") CFL.subFromList(currentDirectory, newListItem=newPath, type="Directory") currentDirectory = CFL.getFile("Directory") self.ui.directoriesTextBrowser.setText('\n'.join( str(result) for result in currentDirectory))
def onSave(*args): dir = CFL.getFile("Directory") if len(dir) < 1: directoryMain.makeDirectoryWidgetMain() currentLocation = cmds.file(q=True, loc=True) currentSceneName = cmds.file(file, q=True, shn=True, sn=True) if CFL.checkSaveLocation(currentLocation, currentSceneName) is True: # print("hey, we're doing it!") # get the current name, trimming the file location data currentName = cmds.file(file, q=True, sn=True, shn=True) # make sure it's a string, and give it to the validation stringName = str(currentName) # ask it to validate the name validateResult = FV.validateFileName(stringName) if type(validateResult) is not NoneType: # if things weren't right then we need to open the UI to tell the user that cmds.file(rename='TEMP.ma') if popWantBool is False: errorMessage = "This name has one or more formatting errors, they are as follows: " + str( validateResult) om.MGlobal.displayError(errorMessage) cmds.evalDeferred( 'om.MGlobal.displayError("This name has one or more formatting errors, check log! Click on semicolon to the right of this line.")' ) else: IM.makeInterruptSaveWidgetMain(desiredName=stringName) if type(validateResult) is NoneType: print("This name passed all the rules!") if CFL.checkSaveLocation(currentLocation, currentSceneName) is False: print("We don't need to check file names in this location")
def __init__(self, parent=None): #call the widget constructor super(directoryWidget, self).__init__(parent=parent) #create widget object from ui file self.ui = PEG.Ui_Form() self.ui.setupUi(self) #currentDirectory = CFL.getDirectory() currentDirectory = CFL.getFile("Directory") self.ui.directoriesTextBrowser.setText('\n'.join( str(result) for result in currentDirectory)) currentDescList = CFL.getFile("DescriptionList") self.ui.DescTextBrowser.setText('\n'.join( str(result) for result in currentDescList)) currentStateList = CFL.getFile("StateList") self.ui.StatesTextBrowser.setText('\n'.join( str(result) for result in currentStateList)) #making slot for add button on directory @QtCore.Slot(name='clickedAddDirect') def clickedAddDirect(): #add current thing to the directory list newPath = self.ui.directoriesLineEdit.text() newPath = cleanPath(newPath) #print(newPath) currentDirectory = CFL.getFile("Directory") CFL.addToList(currentDirectory, newListItem=newPath, type="Directory") currentDirectory = CFL.getFile("Directory") self.ui.directoriesTextBrowser.setText('\n'.join( str(result) for result in currentDirectory)) # making slot for delete button on directory @QtCore.Slot(name='clickedDeleteDirect') def clickedDeleteDirect(): # add current thing to the directory list newPath = self.ui.directoriesLineEdit.text() newPath = cleanPath(newPath) #print(newPath) currentDirectory = CFL.getFile("Directory") CFL.subFromList(currentDirectory, newListItem=newPath, type="Directory") currentDirectory = CFL.getFile("Directory") self.ui.directoriesTextBrowser.setText('\n'.join( str(result) for result in currentDirectory)) @QtCore.Slot(name='clickedAddDesc') def clickedAddDesc(): #add current thing to the desc list newItem = self.ui.DescLineEdit.text() #get current list currentDescList = CFL.getFile("DescriptionList") CFL.addToList(currentDescList, newListItem=newItem, type="DescList") currentDescList = CFL.getFile("DescriptionList") self.ui.DescTextBrowser.setText('\n'.join( str(result) for result in currentDescList)) @QtCore.Slot(name='clickedDelDesc') def clickedDelDesc(): # add current thing to the desc list newItem = self.ui.DescLineEdit.text() # get current list currentDescList = CFL.getFile("DescriptionList") CFL.subFromList(currentDescList, newListItem=newItem, type="DescList") currentDescList = CFL.getFile("DescriptionList") self.ui.DescTextBrowser.setText('\n'.join( str(result) for result in currentDescList)) @QtCore.Slot(name='clickedAddState') def clickedAddState(): # add current thing to the desc list newItem = self.ui.StatesLineEdit.text() # get current list currentStateList = CFL.getFile("StateList") CFL.addToList(currentStateList, newListItem=newItem, type="StateList") currentStateList = CFL.getFile("StateList") self.ui.StatesTextBrowser.setText('\n'.join( str(result) for result in currentStateList)) @QtCore.Slot(name='clickedDelState') def clickedDelState(): # add current thing to the desc list newItem = self.ui.StatesLineEdit.text() # get current list currentStateList = CFL.getFile("StateList") CFL.subFromList(currentStateList, newListItem=newItem, type="StateList") currentStateList = CFL.getFile("StateList") self.ui.StatesTextBrowser.setText('\n'.join( str(result) for result in currentStateList)) #making slot for help button @QtCore.Slot(name='clickedHelp') def clickedHelp(): # open help UI #newPath = self.ui.directoriesLineEdit.text() #print(newPath) DM.makeDirectoryHelpWidgetMain() def cleanPath(path): #need to clean up all paths #TO DO make this cleanup more robust making sure they can't pass in things that are not file paths! newPath = str(path).replace('\\', '/') #print(newPath+ " Clean!") return newPath #connecting slots self.ui.AddButtonDirect.clicked.connect(clickedAddDirect) self.ui.DelButtonDirect.clicked.connect(clickedDeleteDirect) self.ui.helpButton.clicked.connect(clickedHelp) self.ui.DescAddButton.clicked.connect(clickedAddDesc) self.ui.DescDelButton.clicked.connect(clickedDelDesc) self.ui.StatesAddButton.clicked.connect(clickedAddState) self.ui.StatesDelButton.clicked.connect(clickedDelState)
def validateFileName(name): results = [] print(str(name)) nameParts = name.split("_") print(str(nameParts)) if len(nameParts) > 4: #print("was too many parts"); results.append( "This name had too many pieces to it," " please make names four parts like this: Name_Description_State_Version" ) elif len(nameParts) < 4: #print("had too few parts"); results.append( "This name had too few pieces to it, " "please make names four parts like this: Name_Description_State_Version" ) partsCount = len(nameParts) i = 1 while i < partsCount: #print(str(i)); # to do replace with string formatting # take Description[part 2] from the name and compare against the description list. if i is 1 and str( nameParts[1]).lower() not in CFL.getFile("DescriptionList"): results.append( "Part two of your name must be one of the following: " + str(CFL.getFile("DescriptionList"))) # take State from the name and compare against the state list. elif i is 2 and str( nameParts[2]).lower() not in CFL.getFile("StateList"): results.append( "Part three of your name must be one of the following: " + str(CFL.getFile("StateList"))) elif i is 3: #taking off the .ma at the end of the file name by splitting it and never using the second part version = str(nameParts[3]).split(".") match = re.search("([a-zA-Z]+)(\d*)", str(version[0])) if match: #match.group(1) # the string part #print(str(match.group(1)).lower()); if type(match.group(2)) is NoneType: print("It was nothing") # trying to catch people saying finalfinal, a very common practice. if str(match.group(1)).lower() == "finalfinal": results.append( "Finalfinal is not an allowed declaration of a final version." ) elif str(match.group(1)).lower( ) == "final" and match.group(2).__len__() > 0: #print("final isn't supposed to have a number dummy"); results.append( "Final versions are not allowed to include numbers, the final is the final." ) elif str(match.group(1)).lower() == "final": break elif str(match.group(1)).lower() in versionList: if len(match.group(2)) <= 1: results.append( "Version tags must have more than one number behind them. If the number is less" " than 10, start with a 0. Eg. Ver03") elif str(match.group(1)).lower() in testList: break elif str(match.group(1)).lower() not in versionList: results.append( "The version portion of the name must include one of the following: " + str(versionList)) else: results.append( "The final part of the file name must be either some form of Test," " final, or a version identifier") match.group(2) # the number part print(str(match.group(2))) i = i + 1 if results.__len__() > 0: return results else: return None
import re from types import * import checkFileLocation as CFL #Validating a file name # must be a four part name # with specific values in parts 2, 3, and 4 descList = [ "character", "char", "characters", "chars", "prop", "set", "item", "environment", "envir", "other" ] descList = CFL.getFile("DescriptionList") stateList = [ "modeling", "texturing", "rigging", "ready", "animation", "anim", "rig", "other" ] stateList = CFL.getFile("StateList") versionList = ["version", "v", "ver"] testList = ["test", "testing", "t"] #define the validation function print("defined validation function") def validateFileName(name): results = [] print(str(name)) nameParts = name.split("_")