code: def approve(self, filepath):
          
  
          try:
              signature_valid = self.validate_signature(filepath)
  
          except ValueError:
              # GPG is not installed
              signature_valid = False
  
          if signature_valid:
              self.leave_safe_mode()
              post_command_event(self.main_window, self.SafeModeExitMsg)
  
              statustext = _("Valid signature found. File is trusted.")
              post_command_event(self.main_window, self.StatusBarMsg,
                                 text=statustext)
  
          else:
              self.enter_safe_mode()
              post_command_event(self.main_window, self.SafeModeEntryMsg)
  
              statustext = \
                  _("File is not properly signed. Safe mode "
                    "activated. Select File -> Approve to leave safe mode.")
              post_command_event(self.main_window, self.StatusBarMsg,
                                 text=statustext)
docs: Sets safe mode if signature missing of invalid