Browse Source

Fix style for pep8

Chris Adams 5 years ago
parent
commit
5b6a4ead6c
1 changed files with 16 additions and 9 deletions
  1. 16 9
      only_show_green_results.py

+ 16 - 9
only_show_green_results.py

@@ -32,10 +32,15 @@ class GreenCheck:
             self.db = False
             self.db = False
             if allow_api_connections:
             if allow_api_connections:
                 logger.debug(f"No database found at {database_name}.")
                 logger.debug(f"No database found at {database_name}.")
-                logger.debug(f"Falling back to the instead of the Greencheck API, as 'allow_api_connections' is set to {allow_api_connections}.")
+                logger.debug(
+                    (f"Falling back to the instead of the Greencheck API, as ",
+                     "'allow_api_connections' is set to {allow_api_connections}.")
+                )
             else:
             else:
-                logger.debug(f"No database found at {database_name}. Not making any checks, because 'allow_api_connections' is set to {allow_api_connections}")
-
+                logger.debug(
+                    f("No database found at {database_name}. Not making any checks ",
+                      "because 'allow_api_connections' is set to {allow_api_connections}")
+                )
 
 
     def check_url(self, url=None) -> bool:
     def check_url(self, url=None) -> bool:
         """
         """
@@ -70,12 +75,13 @@ class GreenCheck:
         #  https://docs.python.org/3.8/library/sqlite3.html#//apple_ref/Function/sqlite3.connect
         #  https://docs.python.org/3.8/library/sqlite3.html#//apple_ref/Function/sqlite3.connect
         # https://sqlite.org/lockingv3.html
         # https://sqlite.org/lockingv3.html
         with sqlite3.connect(
         with sqlite3.connect(
-                f"file:{database_name}?mode=ro", uri=True, check_same_thread=False
-            ) as con:
+            f"file:{database_name}?mode=ro",
+            uri=True,
+            check_same_thread=False
+        ) as con:
             cur = con.cursor()
             cur = con.cursor()
             cur.execute("SELECT green FROM green_presenting WHERE url=? LIMIT 1",
             cur.execute("SELECT green FROM green_presenting WHERE url=? LIMIT 1",
-                [domain]
-            )
+                        [domain])
             res = cur.fetchone()
             res = cur.fetchone()
             logger.debug(res)
             logger.debug(res)
             return bool(res)
             return bool(res)
@@ -94,6 +100,8 @@ greencheck = GreenCheck()
 # attach callback to the post search hook
 # attach callback to the post search hook
 #  request: flask request object
 #  request: flask request object
 #  ctx: the whole local context of the pre search hook
 #  ctx: the whole local context of the pre search hook
+
+
 def post_search(request, search):
 def post_search(request, search):
     green_results = [
     green_results = [
         entry for entry in list(search.result_container._merged_results)
         entry for entry in list(search.result_container._merged_results)
@@ -102,10 +110,9 @@ def post_search(request, search):
     search.result_container._merged_results = green_results
     search.result_container._merged_results = green_results
     return True
     return True
 
 
+
 def get_green(result):
 def get_green(result):
     logger.debug(result.get('url'))
     logger.debug(result.get('url'))
     green = greencheck.check_url(result.get('url'))
     green = greencheck.check_url(result.get('url'))
     if green:
     if green:
         return True
         return True
-
-