]> git.mxchange.org Git - fba.git/blobdiff - fba/federation/pleroma.py
Fixed some issues found by pylint:
[fba.git] / fba / federation / pleroma.py
index 06b7a4d869219875b5888392cfb4224d30e27102..4c5d72656e3f9aa0c946e690874530258360f5c1 100644 (file)
@@ -24,18 +24,18 @@ from fba import instances
 
 def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
     # DEBUG: print(f"DEBUG: domain='{domain}',origin='{origin}',nodeinfo_url='{nodeinfo_url}' - CALLED!")
-    if type(domain) != str:
+    if not isinstance(domain, str):
         raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
     elif domain == "":
-        raise ValueError(f"Parameter 'domain' is empty")
-    elif type(origin) != str and origin != None:
+        raise ValueError("Parameter 'domain' is empty")
+    elif not isinstance(origin, str) and origin is not None:
         raise ValueError(f"Parameter origin[]={type(origin)} is not 'str'")
     elif origin == "":
-        raise ValueError(f"Parameter 'origin' is empty")
-    elif type(nodeinfo_url) != str:
+        raise ValueError("Parameter 'origin' is empty")
+    elif not isinstance(nodeinfo_url, str):
         raise ValueError(f"Parameter nodeinfo_url[]={type(nodeinfo_url)} is not 'str'")
     elif nodeinfo_url == "":
-        raise ValueError(f"Parameter 'nodeinfo_url' is empty")
+        raise ValueError("Parameter 'nodeinfo_url' is empty")
 
     try:
         # Blocks
@@ -94,7 +94,7 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                         searchres = fba.cursor.fetchone()
                         # DEBUG: print("DEBUG: searchres[]:", type(searchres))
 
-                        if searchres == None:
+                        if searchres is None:
                             print(f"WARNING: Cannot deobsfucate blocked='{blocked}' - SKIPPED!")
                             continue
 
@@ -152,7 +152,7 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                 for blocked, reason in info.items():
                     # DEBUG: print(f"DEBUG: blocked='{blocked}',reason='{reason}' - BEFORE!")
                     blocked = fba.tidyup_domain(blocked)
-                    reason  = fba.tidyup_reason(reason) if reason != None and reason != "" else None
+                    reason  = fba.tidyup_reason(reason) if reason is not None and reason != "" else None
                     # DEBUG: print(f"DEBUG: blocked='{blocked}',reason='{reason}' - AFTER!")
 
                     if blocked == "":
@@ -171,7 +171,7 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                         )
                         searchres = fba.cursor.fetchone()
 
-                        if searchres == None:
+                        if searchres is None:
                             print(f"WARNING: Cannot deobsfucate blocked='{blocked}' - SKIPPED!")
                             continue
 
@@ -194,7 +194,7 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                             entry["reason"] = reason["reason"]
 
         fba.connection.commit()
-    except Exception as e:
-        print(f"ERROR: domain='{domain}',software='pleroma',exception[{type(e)}]:'{str(e)}'")
+    except Exception as exception:
+        print(f"ERROR: domain='{domain}',software='pleroma',exception[{type(exception)}]:'{str(exception)}'")
 
     # DEBUG: print("DEBUG: EXIT!")