def on_pb_validate_selected_clicked(self): ''' User clicked the validate selected button ''' # Get all the selected variables selected_rows = set() map(selected_rows.add, [i.row() for i in self.variables_table.selectedIndexes()]) # Setup GUI for batch run self.pb_cancel_validation.setEnabled(True) self._set_problem_variables([]) self.progress_validation.setValue(0) self.group_progress.setVisible(True) self.variables_table.setEnabled( False) # disable selecting variables during run self.group_progress.setTitle('Validating %d variables...' % len(selected_rows)) # Set the expression library in VariableFactory to the variables for this configuration. # We need to get this from the VariablesTableModel rather than from the xml configuration # since newly added variables may not yet have been saved to the xml configuration but we # still want to check them. VariableFactory().set_expression_library( self.model.get_variables_dict()) # Batch process the selected variables variables = [self.model.variables[i] for i in selected_rows] func = self.validator.check_data_errors var_key = 'dataerror' callback = self.update_validation_progress cancel_flag = self.cancel_validation_flag results = variable_batch_check(variables=variables, validator_func=func, variable_key=var_key, progress_callback=callback, cancel_flag=cancel_flag) # Setup GUI for investigating results self.pb_cancel_validation.setEnabled(False) self.progress_validation.setValue(100) self.variables_table.setEnabled(True) failed_variables = [(var, msg) for (var, flag, msg) in results if flag is False] self._set_problem_variables(failed_variables) self._show_problem_variables() self.group_progress.setVisible(False) if failed_variables: self.pb_problems.setFocus()
def on_pb_validate_selected_clicked(self): ''' User clicked the validate selected button ''' # Get all the selected variables selected_rows = set() map(selected_rows.add, [i.row() for i in self.variables_table.selectedIndexes()]) # Setup GUI for batch run self.pb_cancel_validation.setEnabled(True) self._set_problem_variables([]) self.progress_validation.setValue(0) self.group_progress.setVisible(True) self.variables_table.setEnabled(False) # disable selecting variables during run self.group_progress.setTitle('Validating %d variables...' % len(selected_rows)) # Set the expression library in VariableFactory to the variables for this configuration. # We need to get this from the VariablesTableModel rather than from the xml configuration # since newly added variables may not yet have been saved to the xml configuration but we # still want to check them. VariableFactory().set_expression_library(self.model.get_variables_dict()) # Batch process the selected variables variables = [self.model.variables[i] for i in selected_rows] func = self.validator.check_data_errors var_key = 'dataerror' callback = self.update_validation_progress cancel_flag = self.cancel_validation_flag results = variable_batch_check(variables = variables, validator_func = func, variable_key = var_key, progress_callback = callback, cancel_flag = cancel_flag) # Setup GUI for investigating results self.pb_cancel_validation.setEnabled(False) self.progress_validation.setValue(100) self.variables_table.setEnabled(True) failed_variables = [(var, msg) for (var, flag, msg) in results if flag is False] self._set_problem_variables(failed_variables) self._show_problem_variables() self.group_progress.setVisible(False) if failed_variables: self.pb_problems.setFocus()
def on_pb_validate_selected_released(self): ''' User clicked the validate selected button ''' # Get all the selected variables selected_rows = set() map(selected_rows.add, [i.row() for i in self.variables_table.selectedIndexes()]) # Setup GUI for batch run self.pb_cancel_validation.setEnabled(True) self._set_problem_variables([]) self.progress_validation.setValue(0) self.group_progress.setVisible(True) self.variables_table.setEnabled(False) # disable selecting variables during run self.group_progress.setTitle('Validating %d variables...' % len(selected_rows)) # Batch process the selected variables variables = [self.model.variables[i] for i in selected_rows] func = self.validator.check_data_errors var_key = 'dataerror' callback = self.update_validation_progress cancel_flag = self.cancel_validation_flag results = variable_batch_check(variables = variables, validator_func = func, variable_key = var_key, progress_callback = callback, cancel_flag = cancel_flag) # Setup GUI for investigating results self.pb_cancel_validation.setEnabled(False) self.progress_validation.setValue(100) self.variables_table.setEnabled(True) failed_variables = [(var, msg) for (var, flag, msg) in results if flag is False] self._set_problem_variables(failed_variables) self._show_problem_variables() self.group_progress.setVisible(False) if failed_variables: self.pb_problems.setFocus()