AV-98-fork

A fork of https://tildegit.org/solderpunk/AV-98
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit 3207f8b3824933128b7b890d99e85333811d6b4f
parent 6bb2e20e6981dc2b32978ef30f5756da1ed54b36
Author: Solderpunk <solderpunk@sdf.org>
Date:   Sun, 10 May 2020 13:48:25 +0200

Reduce code duplication.

Diffstat:
Mav98.py | 13+++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/av98.py b/av98.py @@ -270,9 +270,7 @@ class GeminiClient(cmd.Cmd): print("Keeping certificate active for {}".format(gi.host)) else: print("Deactivating certificate.") - self.client_certs["active"] = None - self.active_cert_domains = [] - self.prompt = self.no_cert_prompt + self._deactivate_client_cert() # Do everything which touches the network in one block, # so we only need to catch exceptions once try: @@ -612,6 +610,11 @@ Slow internet connection? Use 'set timeout' to be more patient.""") debug_text = "\x1b[0;32m[DEBUG] " + debug_text + "\x1b[0m" print(debug_text) + def _deactivate_client_cert(self): + self.client_certs["active"] = None + self.active_cert_domains = [] + self.prompt = self.no_cert_prompt + # Cmd implementation follows def default(self, line): @@ -693,9 +696,7 @@ Slow internet connection? Use 'set timeout' to be more patient.""") """Set or clear a client certificate""" if self.client_certs["active"]: print("Deactivating client certificate.") - self.client_certs["active"] = None - self.active_cert_domains = [] - self.prompt = self.no_cert_prompt + self._deactivate_client_cert() else: print("Loading client certificate file, in PEM format (blank line to cancel)") certfile = input("Certfile path: ")