def validateInput(self, e): '''Perform sanity checks on input and determine wheter it's useful to enable "Make" button.''' # Avoid endless recursion if self.inputEvaluated: return self.inputEvaluated = True if not self.inputField.GetValue() or not os.path.exists( self.inputField.GetValue()): # TODO or allow not specifying input in the case where ADD or SUB targets are added? Just like the cmdline version if self.inputFromFolder: self.status.SetLabel( "No input folder given or folder does not exist.") else: self.status.SetLabel( "No input file given or input file does not exist.") self.makeBtn.Disable() elif self.inputFromFolder and not os.path.isdir( self.inputField.GetValue()): self.status.SetLabel( "Illegal input option. A path is expected, not a file.") self.makeBtn.Disable() elif not self.inputFromFolder and not os.path.isfile( self.inputField.GetValue()): self.status.SetLabel( "Illegal input option. A file is expected, not a path.") self.makeBtn.Disable() elif not self.inputFromFolder and not self.outputField.GetValue(): self.status.SetLabel("No output path specified.") self.makeBtn.Disable() elif not self.inputFromFolder and os.path.isdir( self.outputField.GetValue()): self.status.SetLabel( "Output path is an existing folder, cannot overwrite it.") self.makeBtn.Disable() elif not self.inputFromFolder and self.outputObj and not maketarget.isObjFile( self.outputField.GetValue()): self.status.SetLabel( "The specified output file should be a .obj file.") self.makeBtn.Disable() elif not self.inputFromFolder and not self.outputObj and not maketarget.isTargetFile( self.outputField.GetValue()): self.status.SetLabel( "The specified output file should be a .target file.") self.makeBtn.Disable() else: self.status.SetLabel("Ready to make target.") self.makeBtn.Enable() self.inputEvaluated = False return
def validateInput(self, e): '''Perform sanity checks on input and determine wheter it's useful to enable "Make" button.''' # Avoid endless recursion if self.inputEvaluated: return self.inputEvaluated = True if not self.inputField.GetValue() or not os.path.exists(self.inputField.GetValue()): # TODO or allow not specifying input in the case where ADD or SUB targets are added? Just like the cmdline version if self.inputFromFolder: self.status.SetLabel("No input folder given or folder does not exist.") else: self.status.SetLabel("No input file given or input file does not exist.") self.makeBtn.Disable() elif self.inputFromFolder and not os.path.isdir(self.inputField.GetValue()): self.status.SetLabel("Illegal input option. A path is expected, not a file.") self.makeBtn.Disable() elif not self.inputFromFolder and not os.path.isfile(self.inputField.GetValue()): self.status.SetLabel("Illegal input option. A file is expected, not a path.") self.makeBtn.Disable() elif not self.inputFromFolder and not self.outputField.GetValue(): self.status.SetLabel("No output path specified.") self.makeBtn.Disable() elif not self.inputFromFolder and os.path.isdir(self.outputField.GetValue()): self.status.SetLabel("Output path is an existing folder, cannot overwrite it.") self.makeBtn.Disable() elif not self.inputFromFolder and self.outputObj and not maketarget.isObjFile(self.outputField.GetValue()): self.status.SetLabel("The specified output file should be a .obj file.") self.makeBtn.Disable() elif not self.inputFromFolder and not self.outputObj and not maketarget.isTargetFile(self.outputField.GetValue()): self.status.SetLabel("The specified output file should be a .target file.") self.makeBtn.Disable() else: self.status.SetLabel("Ready to make target.") self.makeBtn.Enable() self.inputEvaluated = False return