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)
)
# 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"):
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!")
# 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
}