]> git.mxchange.org Git - fba.git/blobdiff - fba/commands.py
Fixed some issues found by pylint:
[fba.git] / fba / commands.py
index dedaf0ab6e920f787cb9c8c0b12ded0a09735b14..65ddb03f80ad5a07335b88185ccbc9fa26cd91c0 100644 (file)
@@ -74,7 +74,7 @@ def fetch_bkali(args: argparse.Namespace):
         for entry in fetched["data"]["nodeinfo"]:
             # DEBUG: print(f"DEBUG: entry['{type(entry)}']='{entry}'")
             if not "domain" in entry:
-                print(f"WARNING: entry does not contain 'domain' - SKIPPED!")
+                print(f"WARNING: entry()={len(entry)} does not contain 'domain' - SKIPPED!")
                 continue
             elif not validators.domain(entry["domain"]):
                 print(f"WARNING: domain='{entry['domain']}' is not a valid domain - SKIPPED!")
@@ -89,8 +89,8 @@ def fetch_bkali(args: argparse.Namespace):
             # DEBUG: print(f"DEBUG: Adding domain='{entry['domain']}' ...")
             domains.append(entry["domain"])
 
-    except BaseException as e:
-        print(f"ERROR: Cannot fetch graphql,exception[{type(e)}]:'{str(e)}'")
+    except BaseException as exception:
+        print(f"ERROR: Cannot fetch graphql,exception[{type(exception)}]:'{str(exception)}'")
         sys.exit(255)
 
     # DEBUG: print(f"DEBUG: domains()={len(domains)}")
@@ -106,7 +106,7 @@ def fetch_bkali(args: argparse.Namespace):
 
 def fetch_blocks(args: argparse.Namespace):
     # DEBUG: print(f"DEBUG: args[]={type(args)} - CALLED!")
-    if args.domain != None and args.domain != "":
+    if args.domain is not None and args.domain != "":
         # DEBUG: print(f"DEBUG: args.domain='{args.domain}' - checking ...")
         if not validators.domain(args.domain):
             print(f"WARNING: domain='{args.domain}' is not valid.")
@@ -120,7 +120,7 @@ def fetch_blocks(args: argparse.Namespace):
 
     boot.acquire_lock()
 
-    if args.domain != None and args.domain != "":
+    if args.domain is not None and args.domain != "":
         # Re-check single domain
         fba.cursor.execute(
             "SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software IN ('pleroma', 'mastodon', 'friendica', 'misskey', 'bookwyrm', 'takahe') AND domain = ?", [args.domain]
@@ -177,7 +177,7 @@ def fetch_blocks(args: argparse.Namespace):
                         blocked, reason = block.values()
                         # 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 == "":
@@ -194,7 +194,7 @@ def fetch_blocks(args: argparse.Namespace):
 
                             searchres = fba.cursor.fetchone()
 
-                            if searchres == None:
+                            if searchres is None:
                                 print(f"WARNING: Cannot deobsfucate blocked='{blocked}' - SKIPPED!")
                                 continue
 
@@ -209,7 +209,7 @@ def fetch_blocks(args: argparse.Namespace):
 
                             searchres = fba.cursor.fetchone()
 
-                            if searchres == None:
+                            if searchres is None:
                                 print(f"WARNING: Cannot deobsfucate blocked='{blocked}' - SKIPPED!")
                                 continue
 
@@ -243,8 +243,8 @@ def fetch_blocks(args: argparse.Namespace):
 
                 # DEBUG: print("DEBUG: Committing changes ...")
                 fba.connection.commit()
-            except Exception as e:
-                print(f"ERROR: blocker='{blocker}',software='{software}',exception[{type(e)}]:'{str(e)}'")
+            except Exception as exception:
+                print(f"ERROR: blocker='{blocker}',software='{software}',exception[{type(exception)}]:'{str(exception)}'")
         else:
             print("WARNING: Unknown software:", blocker, software)
 
@@ -277,8 +277,8 @@ def fetch_cs(args: argparse.Namespace):
         # DEBUG: print(f"DEBUG: blocked[]={type(blocked)}")
         domains["reject"] = domains["reject"] + fba.find_domains(blocked)
 
-    except BaseException as e:
-        print(f"ERROR: Cannot fetch from meta.chaos.social,exception[{type(e)}]:'{str(e)}'")
+    except BaseException as exception:
+        print(f"ERROR: Cannot fetch from meta.chaos.social,exception[{type(exception)}]:'{str(exception)}'")
         sys.exit(255)
 
     # DEBUG: print(f"DEBUG: domains()={len(domains)}")
@@ -335,8 +335,8 @@ def fetch_fba_rss(args: argparse.Namespace):
                 # DEBUG: print(f"DEBUG: Adding domain='{domain}'")
                 domains.append(domain)
 
-    except BaseException as e:
-        print(f"ERROR: Cannot fetch feed='{feed}',exception[{type(e)}]:'{str(e)}'")
+    except BaseException as exception:
+        print(f"ERROR: Cannot fetch feed='{feed}',exception[{type(exception)}]:'{str(exception)}'")
         sys.exit(255)
 
     # DEBUG: print(f"DEBUG: domains()={len(domains)}")
@@ -388,8 +388,8 @@ def fetch_fbabot_atom(args: argparse.Namespace):
                         # DEBUG: print(f"DEBUG: Adding domain='{domain}',domains()={len(domains)}")
                         domains.append(domain)
 
-    except BaseException as e:
-        print(f"ERROR: Cannot fetch feed='{feed}',exception[{type(e)}]:'{str(e)}'")
+    except BaseException as exception:
+        print(f"ERROR: Cannot fetch feed='{feed}',exception[{type(exception)}]:'{str(exception)}'")
         sys.exit(255)
 
     # DEBUG: print(f"DEBUG: domains({len(domains)})={domains}")