summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Yin <fkfd@macaw.me>2020-11-14 15:39:33 +0800
committerFrederick Yin <fkfd@macaw.me>2020-11-14 15:39:33 +0800
commit759c5aee3519322559fd20fe1e9b32fa19091dcc (patch)
treeea9934fd3c78d80715e03d971fba907767c05c0e
parent50fd6639c6bc450030ea8e281f029e6df8cdcb0d (diff)
Enhance comments
-rw-r--r--picross/gui/controller.py4
-rw-r--r--picross/gui/dialog.py3
-rw-r--r--picross/tofu.py15
3 files changed, 13 insertions, 9 deletions
diff --git a/picross/gui/controller.py b/picross/gui/controller.py
index 86631be..d3efbce 100644
--- a/picross/gui/controller.py
+++ b/picross/gui/controller.py
@@ -125,7 +125,6 @@ class Controller:
url = GeminiUrl.parse(raw_url, self.tab.history.get_current_url())
if new_tab:
self.new_tab(url=url) # Can't know the title yet
-
await self.visit_link(url)
except NonAbsoluteUrlWithoutContextError:
await self.put_gui_op(
@@ -196,7 +195,7 @@ class Controller:
def untrusted_cert_callback(
self, url: GeminiUrl, old_cert: tofu.TofuEntry, new_cert: tofu.TofuEntry
):
- # not async because the result has to be waited for
+ # not async because the result has to be awaited
trust = messagebox.askyesno(
"Untrusted certificate",
"\n".join(
@@ -364,4 +363,3 @@ class Controller:
match = re.match(r"^(#{1,3})\s+(.+)$", fragment)
heading = match.group(2)
self.view.scroll_to_fragment(re.sub("\s", "_", heading))
-
diff --git a/picross/gui/dialog.py b/picross/gui/dialog.py
index 8bc0e35..ce1a681 100644
--- a/picross/gui/dialog.py
+++ b/picross/gui/dialog.py
@@ -104,8 +104,6 @@ class Dialog:
)
def get(self):
- import time
-
# blocking method
# returns value when it is submitted and None when canceled
while self.value is None and not self.canceled:
@@ -115,4 +113,3 @@ class Dialog:
break
pass
return self.value
-
diff --git a/picross/tofu.py b/picross/tofu.py
index da644ea..d2fc3d8 100644
--- a/picross/tofu.py
+++ b/picross/tofu.py
@@ -34,6 +34,8 @@ class TofuDatabase:
self.db_file = Path(user_config_dir("picross")) / "tofu.csv"
def read(self) -> list:
+ """Reads all TOFU entries from DB
+ """
with open(self.db_file) as f:
reader = csv.reader(f)
tofu_entries = [
@@ -44,6 +46,8 @@ class TofuDatabase:
return tofu_entries
def append(self, entry: TofuEntry):
+ """Writes one TOFU entry to DB
+ """
with open(self.db_file, "a") as f:
writer = csv.writer(f)
writer.writerow(
@@ -52,7 +56,8 @@ class TofuDatabase:
f.close()
def revoke(self, idx: int):
- # remove entry no. idx from db
+ """Remove entry #idx from DB
+ """
entries = self.read()
with open(self.db_file, "w") as f:
writer = csv.writer(f)
@@ -60,8 +65,10 @@ class TofuDatabase:
f.close()
async def handle_url(self, url):
- # takes GeminiUrl
- # returns boolean whether to proceed visiting the page
+ """Method called each time a connection is made to a server
+ Takes a GeminiUrl, checks against DB,
+ returns boolean whether to proceed visiting the page
+ """
pem_str = await curio.ssl.get_server_certificate((url.host, url.port))
cert = x509.load_pem_x509_certificate(pem_str.encode("utf-8"))
sha256 = hashlib.sha256(pem_str.encode("utf-8")).hexdigest()
@@ -99,6 +106,8 @@ class TofuDatabase:
def system_certs() -> str:
+ """Currently unused. System-trusted certs have no privilege in picross.
+ """
ca_file = "/etc/ssl/cert.pem"
with open(ca_file) as f:
certs = f.read()