]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 21 Jun 2023 17:44:35 +0000 (19:44 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 21 Jun 2023 17:44:35 +0000 (19:44 +0200)
- directly imported format_datetime to keep loading time short
- fixed syntax errors

api.py
fba/commands.py
fba/http/federation.py
fba/networks/friendica.py
fba/networks/lemmy.py
fba/networks/mastodon.py
fba/networks/pleroma.py
fba/utils.py

diff --git a/api.py b/api.py
index ea353035aeda6a85a4da5be8aeb93fb45ee5b504..4b4b4da5eb2f04d5d3a869aabfcb41c6aaac6a30 100644 (file)
--- a/api.py
+++ b/api.py
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-from datetime import datetime
-from email import utils
-
 import re
 
+from datetime import datetime
+from email.utils import format_datetime
 from fastapi import Request, HTTPException, Query
 from fastapi.responses import JSONResponse
 from fastapi.responses import PlainTextResponse
@@ -285,13 +284,13 @@ def rss(request: Request, domain: str = None):
             "blocked"    : row[1],
             "block_level": row[2],
             "reason"     : "Provided reason: '" + row[3] + "'" if row[3] is not None and row[3] != "" else "No reason provided.",
-            "first_seen" : utils.format_datetime(datetime.fromtimestamp(row[4])),
-            "last_seen"  : utils.format_datetime(datetime.fromtimestamp(row[5])),
+            "first_seen" : format_datetime(datetime.fromtimestamp(row[4])),
+            "last_seen"  : format_datetime(datetime.fromtimestamp(row[5])),
         })
 
     return templates.TemplateResponse("rss.xml", {
         "request"  : request,
-        "timestamp": utils.format_datetime(datetime.now()),
+        "timestamp": format_datetime(datetime.now()),
         "domain"   : domain,
         "hostname" : config.get("hostname"),
         "blocks"   : blocklist
index 9ba1ff7905f6f81b826b44969a6bc23190a9117c..d1cf4c507032ab1caa94837279e884fe7badbc68 100644 (file)
@@ -358,7 +358,7 @@ def fetch_observer(args: argparse.Namespace):
             domain = item.decode_contents()
 
             logger.debug("domain='%s'", domain)
-            if not utils.is_domain_wanted(domain)
+            if not utils.is_domain_wanted(domain):
                 logger.debug("domain='%s' is not wanted - SKIPPED!", domain)
                 continue
             elif instances.is_registered(domain):
index 5f6616d0b0777baa6d561d63fece9cedada6e6c0..7968384ace0c53a4831717505a367f741680afa7 100644 (file)
@@ -124,7 +124,7 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path:
         if instance == "":
             logger.warning(f"Empty instance after tidyup.domain(), domain='{domain}'")
             continue
-        elif not utils.is_domain_wanted((instance):
+        elif not utils.is_domain_wanted(instance):
             logger.debug("instance='%s' is not wanted - SKIPPED!", instance)
             continue
         elif instance.find("/profile/") > 0 or instance.find("/users/") > 0:
@@ -354,7 +354,7 @@ def fetch_wellknown_nodeinfo(domain: str) -> dict:
                         url = f"https://{domain}{url}"
                         components = urlparse(url)
 
-                    if not utils.is_domain_wanted((components.netloc):
+                    if not utils.is_domain_wanted(components.netloc):
                         logger.debug("components.netloc='%s' is not wanted - SKIPPED!", components.netloc)
                         continue
 
@@ -582,7 +582,7 @@ def find_domains(tag: bs4.element.Tag) -> list:
 
         logger.debug("domain='%s',reason='%s'", domain, reason)
 
-        if not utils.is_domain_wanted((domain):
+        if not utils.is_domain_wanted(domain):
             logger.debug("domain='%s' is blacklisted - SKIPPED!", domain)
             continue
         elif domain == "gab.com/.ai, develop.gab.com":
@@ -638,7 +638,7 @@ def add_peers(rows: dict) -> list:
                 raise ValueError(f"peer[]='{type(peer)}' is not supported,key='{key}'")
 
             logger.debug(f"peer='{peer}' - AFTER!")
-            if not utils.is_domain_wanted((peer):
+            if not utils.is_domain_wanted(peer):
                 logger.debug("peer='%s' is not wanted - SKIPPED!", peer)
                 continue
 
index 8fca3302eb695c88080db184e7ddc13488dbb3f0..3714119119e0630c5bccb2cdff201c8b970bf54f 100644 (file)
@@ -89,7 +89,7 @@ def fetch_blocks(domain: str) -> dict:
         reason  = tidyup.reason(line.find_all("td")[1].text)
         logger.debug(f"blocked='{blocked}',reason='{reason}'")
 
-        if not utils.is_domain_wanted((blocked):
+        if not utils.is_domain_wanted(blocked):
             logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
             continue
 
index c5753865cbe5a3aa42c04c400bddd486371c2a8b..12c40d3c4f71c38cf1991968e9913b96d986048b 100644 (file)
@@ -204,7 +204,7 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                 blocked = tidyup.domain(tag.contents[0])
 
                 logger.debug(f"blocked='{blocked}'")
-                if not utils.is_domain_wanted((blocked):
+                if not utils.is_domain_wanted(blocked):
                     logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
                     continue
                 elif not instances.is_registered(blocked):
index 966477cb7ca7e5ae4b66750c655bc106d9a24f0d..ce662da8fd5ee0bc9ef1b9634a162c68fd98a16f 100644 (file)
@@ -301,7 +301,7 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                     nodeinfo_url = row[2]
 
                 logger.debug("Looking up instance by domain:", blocked)
-                if not utils.is_domain_wanted((blocked):
+                if not utils.is_domain_wanted(blocked):
                     logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
                     continue
                 elif not instances.is_registered(blocked):
@@ -309,7 +309,7 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                     instances.add(blocked, domain, inspect.currentframe().f_code.co_name, nodeinfo_url)
 
                 logger.debug("Looking up instance by domain:", blocked)
-                if not utils.is_domain_wanted((blocked):
+                if not utils.is_domain_wanted(blocked):
                     logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
                     continue
                 elif not instances.is_registered(blocked):
index 8ef7a06a53cb51c7617a32cc1b04ffea75a36beb..7899906708fba85266280d5280aaa5a0f789dca5 100644 (file)
@@ -220,7 +220,7 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                 nodeinfo_url = row[2]
 
             logger.debug(f"blocked='{blocked}'")
-            if not utils.is_domain_wanted((blocked):
+            if not utils.is_domain_wanted(blocked):
                 logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
                 continue
             elif not instances.is_registered(blocked):
@@ -321,7 +321,7 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                     nodeinfo_url = row[2]
 
                 logger.debug(f"blocked='{blocked}'")
-                if not utils.is_domain_wanted((blocked):
+                if not utils.is_domain_wanted(blocked):
                     logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
                     continue
                 elif not instances.is_registered(blocked):
@@ -390,7 +390,7 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                 nodeinfo_url = row[2]
 
             logger.debug(f"blocked='{blocked}'")
-            if not utils.is_domain_wanted((blocked):
+            if not utils.is_domain_wanted(blocked):
                 logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
                 continue
             elif not instances.is_registered(blocked):
@@ -460,7 +460,7 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                         nodeinfo_url = row[2]
 
                     logger.debug(f"blocked='{blocked}'")
-                    if not utils.is_domain_wanted((blocked):
+                    if not utils.is_domain_wanted(blocked):
                         logger.warning("blocked='%s' is not wanted - SKIPPED!", blocked)
                         continue
                     elif not instances.is_registered(blocked):
index 46fa37efee7ca31f8f883390796b17b1ed24a19f..7850b392d707dded0d60c0be0fb2c6f3cb7d8547 100644 (file)
@@ -133,7 +133,7 @@ def process_domain(domain: str, blocker: str, command: str) -> bool:
         logger.debug(f"domain='{domain}' de-obscured to '{row[0]}'")
         domain = row[0]
 
-    if not is_domain_wanted(domain)
+    if not is_domain_wanted(domain):
         logger.debug("domain='%s' is not wanted - SKIPPED!", domain)
         return False
     elif instances.is_recent(domain):