]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 21 Jun 2023 02:39:21 +0000 (04:39 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 21 Jun 2023 02:39:21 +0000 (04:39 +0200)
- ops, fixed variable chaos

fba/networks/friendica.py

index 20814a6d49b9c7901fff6232f7a550cb3d17f952..ffce628cd65b6928ba63613d445a9b34f0f8c537 100644 (file)
@@ -32,8 +32,8 @@ def fetch_blocks(domain: str) -> dict:
     elif domain == "":
         raise ValueError("Parameter 'domain' is empty")
 
-    blocked = list()
-    blocklist = None
+    blocklist = list()
+    block_tag = None
 
     try:
         # DEBUG: print("DEBUG: Fetching friendica blocks from domain:", domain)
@@ -48,18 +48,18 @@ def fetch_blocks(domain: str) -> dict:
         )
         # DEBUG: print(f"DEBUG: doc[]='{type(doc)}'")
 
-        blocklist = doc.find(id="about_blocklist")
+        block_tag = doc.find(id="about_blocklist")
     except network.exceptions as exception:
         print(f"WARNING: Exception '{type(exception)}' during fetching instances (friendica) from domain='{domain}'")
         instances.set_last_error(domain, exception)
         return dict()
 
     # Prevents exceptions:
-    if blocklist is None:
+    if block_tag is None:
         # DEBUG: print("DEBUG: Instance has no block list:", domain)
         return dict()
 
-    table = blocklist.find("table")
+    table = block_tag.find("table")
 
     # DEBUG: print(f"DEBUG: table[]='{type(table)}'")
     if table.find("tbody"):
@@ -71,7 +71,8 @@ def fetch_blocks(domain: str) -> dict:
     for line in rows:
         # DEBUG: print(f"DEBUG: line='{line}'")
         blocked = tidyup.domain(line.find_all("td")[0].text)
-        print(f"DEBUG: blocked='{blocked}'")
+        reason  = tidyup.reason(line.find_all("td")[1].text)
+        # DEBUG: print(f"DEBUG: blocked='{blocked}',reason='{reason}'")
 
         if not validators.domain(blocked):
             print(f"WARNING: blocked='{blocked}' is not a valid domain - SKIPPED!")
@@ -86,13 +87,14 @@ def fetch_blocks(domain: str) -> dict:
             # DEBUG: print(f"DEBUG: blocked='{blocked}' is blacklisted - SKIPPED!")
             continue
 
-        blocked.append({
+        # DEBUG: print(f"DEBUG: Appending blocked='{blocked}',reason='{reason}'")
+        blocklist.append({
             "domain": tidyup.domain(blocked),
-            "reason": tidyup.reason(line.find_all("td")[1].text)
+            "reason": tidyup.reason(reason)
         })
         # DEBUG: print("DEBUG: Next!")
 
     # DEBUG: print("DEBUG: Returning blocklist() for domain:", domain, len(blocklist))
     return {
-        "reject": blocked
+        "reject": blocklist
     }