From b45caa10e7896cae614109c86a55c475c47de01a Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Thu, 1 Sep 2022 17:13:17 +0300 Subject: Refactor "if ... else" block to check the truthy case first * wqflask/wqflask/docs.py (Docs.__init__): Check the truthy case first after fetching the results. --- wqflask/wqflask/docs.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/wqflask/wqflask/docs.py b/wqflask/wqflask/docs.py index 9661f768..06f83c7f 100644 --- a/wqflask/wqflask/docs.py +++ b/wqflask/wqflask/docs.py @@ -12,14 +12,12 @@ class Docs: "FROM Docs WHERE Docs.entry LIKE %s", (str(entry),)) result = cursor.fetchone() self.entry = entry - if result == None: - self.title = self.entry.capitalize() - self.content = "" - else: - + if result: self.title = result[0] self.content = result[1].decode("utf-8") - + else: + self.title = self.entry.capitalize() + self.content = "" self.editable = "false" # ZS: Removing option to edit to see if text still gets vandalized try: -- cgit v1.2.3