From 27a38b41ce81e8391945d17baee306e112e4862c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 9 Jun 2023 12:07:38 +0200 Subject: [PATCH] Continued: - formatted for shorter lines --- fba/federation/friendica.py | 7 ++++++- fba/federation/lemmy.py | 7 ++++++- fba/federation/mastodon.py | 14 ++++++++++++-- fba/federation/peertube.py | 7 ++++++- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/fba/federation/friendica.py b/fba/federation/friendica.py index a596a6c..1a37dfe 100644 --- a/fba/federation/friendica.py +++ b/fba/federation/friendica.py @@ -33,7 +33,12 @@ def fetch_blocks(domain: str) -> dict: try: doc = bs4.BeautifulSoup( - network.fetch_response(domain, "/friendica", network.web_headers, (config.get("connection_timeout"), config.get("read_timeout"))).text, + network.fetch_response( + domain, + "/friendica", + network.web_headers, + (config.get("connection_timeout"), config.get("read_timeout")) + ).text, "html.parser", ) except BaseException as exception: diff --git a/fba/federation/lemmy.py b/fba/federation/lemmy.py index d186b0d..8e07a83 100644 --- a/fba/federation/lemmy.py +++ b/fba/federation/lemmy.py @@ -29,7 +29,12 @@ def fetch_peers(domain: str) -> list: peers = list() try: # DEBUG: print(f"DEBUG: domain='{domain}' is Lemmy, fetching JSON ...") - response = network.fetch_response(domain, "/api/v3/site", network.api_headers, (config.get("connection_timeout"), config.get("read_timeout"))) + response = network.fetch_response( + domain, + "/api/v3/site", + network.api_headers, + (config.get("connection_timeout"), config.get("read_timeout")) + ) data = fba.json_from_response(response) diff --git a/fba/federation/mastodon.py b/fba/federation/mastodon.py index 54a376e..f55a4cd 100644 --- a/fba/federation/mastodon.py +++ b/fba/federation/mastodon.py @@ -69,7 +69,12 @@ def fetch_blocks_from_about(domain: str) -> dict: try: doc = bs4.BeautifulSoup( - network.fetch_response(domain, "/about/more", network.web_headers, (config.get("connection_timeout"), config.get("read_timeout"))).text, + network.fetch_response( + domain, + "/about/more", + network.web_headers, + (config.get("connection_timeout"), config.get("read_timeout")) + ).text, "html.parser", ) except BaseException as exception: @@ -134,7 +139,12 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str): } # DEBUG: print("DEBUG: Querying API domain_blocks:", domain) - response = network.fetch_response(domain, "/api/v1/instance/domain_blocks", network.api_headers, (config.get("connection_timeout"), config.get("read_timeout"))) + response = network.fetch_response( + domain, + "/api/v1/instance/domain_blocks", + network.api_headers, + (config.get("connection_timeout"), config.get("read_timeout")) + ) # DEBUG: print(f"DEBUG: response[]='{type(response)}'") blocklist = fba.json_from_response(response) diff --git a/fba/federation/peertube.py b/fba/federation/peertube.py index f4997ad..2d2ebaf 100644 --- a/fba/federation/peertube.py +++ b/fba/federation/peertube.py @@ -33,7 +33,12 @@ def fetch_peers(domain: str) -> list: # DEBUG: print(f"DEBUG: domain='{domain}',mode='{mode}'") while True: try: - response = network.fetch_response(domain, "/api/v1/server/{mode}?start={start}&count=100", network.api_headers, (config.get("connection_timeout"), config.get("read_timeout"))) + response = network.fetch_response( + domain, + "/api/v1/server/{mode}?start={start}&count=100", + network.api_headers, + (config.get("connection_timeout"), config.get("read_timeout")) + ) data = fba.json_from_response(response) # DEBUG: print(f"DEBUG: response.ok={response.ok},response.status_code='{response.status_code}',data[]='{type(data)}'") -- 2.39.5