#logger.setLevel(logging.DEBUG)
# Lemmy translations
-translations = [
+_translations = [
"Blocked Instances".lower(),
"Instàncies bloquejades".lower(),
"Blocáilte Ásc".lower(),
logger.debug("Marking domain='%s' as successfully handled ...", domain)
instances.set_success(domain)
+ logger.debug("peers()=%d", len(peers))
if len(peers) == 0:
logger.debug("Fetching instances for domain='%s' from /instances ...", domain)
peers = fetch_instances(domain, origin)
elif not isinstance(content, str):
logger.debug("content[]='%s' is not supported/wanted type 'str' - SKIPPED!", type(content))
continue
- elif content.lower() in translations:
+ elif content.lower() in _translations:
logger.debug("Found header='%s' with blocked instances - BREAK(3) !", header)
found = header
break
logger.debug("tag[]='%s'", type(tag))
text = tag.contents[0] if isinstance(tag.contents[0], str) else tag.contents[0].text
- logger.debug("text='%s' - BEFORE!", text)
+ logger.debug("text[%s]='%s' - BEFORE!", type(text), text)
peer = tidyup.domain(text) if text != "" else None
logger.debug("peer='%s' - AFTER", peer)
if len(peers) == 0:
logger.debug("Found no peers for domain='%s', trying script tag ...", domain)
peers = parse_script(doc)
+ logger.debug("Parsing doc()=%d returned %d peer(s).", len(doc), len(peers))
else:
logger.warning("Cannot fetch /instances due to error: response.ok='%s',response.status_code=%d,response.details='%s'", response.ok, response.status_code, response.reason)
instances.set_last_error(domain, response)
data = parsed["routeData"]["federatedInstancesResponse"]["data"]["federated_instances"]
logger.debug("Checking %d data elements ...", len(data))
for element in data:
- logger.debug("element='%s'", element)
+ logger.debug("element[%s]='%s'", type(element), element)
if isinstance(only, str) and only != element:
logger.debug("Skipping unwanted element='%s',only='%s'", element, only)
continue
if "domain" not in row:
logger.warning("row()=%d has no element 'domain' - SKIPPED!", len(row))
continue
+ elif row["domain"] in [None, ""]:
+ logger.debug("row[domain]='%s' is empty - SKIPPED!", row["domain"])
+ continue
logger.debug("row[domain]='%s' - BEFORE!", row["domain"])
peer = tidyup.domain(row["domain"])
continue
elif not domain_helper.is_wanted(peer):
logger.debug("peer='%s' is not wanted - SKIPPED!", peer)
+ continue
elif peer in peers:
logger.debug("peer='%s' already added - SKIPPED!", peer)
continue