]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 21 Jun 2023 02:05:52 +0000 (04:05 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 21 Jun 2023 02:05:52 +0000 (04:05 +0200)
- also moved fba.config to package fba.helpers

17 files changed:
api.py
fba/__init__.py
fba/commands.py
fba/config.py [deleted file]
fba/csrf.py
fba/federation.py
fba/helpers/__init__.py
fba/helpers/config.py [new file with mode: 0644]
fba/models/error_log.py
fba/models/instances.py
fba/network.py
fba/networks/friendica.py
fba/networks/lemmy.py
fba/networks/mastodon.py
fba/networks/misskey.py
fba/networks/peertube.py
fba/networks/pleroma.py

diff --git a/api.py b/api.py
index eb7a8f88a406ebe7038edcdea77d2c88b69730e7..41580f3ac8e0081ad6815f3cd2ec0e53c2ff13a8 100644 (file)
--- a/api.py
+++ b/api.py
@@ -29,10 +29,10 @@ import uvicorn
 import requests
 import validators
 
-from fba import config
 from fba import fba
 from fba import network
 
+from fba.helpers import config
 from fba.helpers import tidyup
 
 router = fastapi.FastAPI(docs_url=config.get("base_url") + "/docs", redoc_url=config.get("base_url") + "/redoc")
index 80128852f62772c4da131cc2f3e86e24c0ca2971..e5e1748759918cf0fe58290bac745bb14a489423 100644 (file)
@@ -17,7 +17,6 @@ __all__ = [
     # Main packages:
     'boot',
     'commands',
-    'config',
     'csrf',
     'federation',
     'fba',
index 4dca5fde1827a72078d6a2c5d1ea2dfcc290124a..24d4840369bc7e269994ad71331464eb9b03884a 100644 (file)
@@ -26,12 +26,12 @@ import markdown
 import reqto
 import validators
 
-from fba import config
 from fba import federation
 from fba import fba
 from fba import network
 
 from fba.helpers import blacklist
+from fba.helpers import config
 from fba.helpers import cookies
 from fba.helpers import locking
 from fba.helpers import tidyup
diff --git a/fba/config.py b/fba/config.py
deleted file mode 100644 (file)
index 1ae1a25..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-# Fedi API Block - An aggregator for fetching blocking data from fediverse nodes
-# Copyright (C) 2023 Free Software Foundation
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published
-# by the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Affero General Public License for more details.
-#
-# 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/>.
-
-import json
-
-with open("config.json") as f:
-    # DEBUG: print("DEBUG: Loading configuration file ...")
-    _config = json.loads(f.read())
-
-def get(key: str) -> any:
-    # DEBUG: print(f"DEBUG: key[{type(key)}]={key} - CALLED!")
-    if not isinstance(key, str):
-        raise ValueError(f"Parameter key[]='{type(key)}' is not 'str'")
-    elif key == "":
-        raise ValueError("Parameter 'key' is empty")
-    elif not key in _config:
-        raise KeyError(f"key='{key}' does not exist in _config array")
-
-    # DEBUG: print(f"DEBUG: _config[{key}]={_config[key]} - EXIT!")
-    return _config[key]
index 859d5cbe338503b27ce93c07d34f86272bf3befc..8cd8c5e625d2930b6ea0ee30ac49f6ceff4fbf3f 100644 (file)
@@ -18,9 +18,9 @@ import bs4
 import reqto
 import validators
 
-from fba import config
 from fba import network
 
+from fba.helpers import config
 from fba.helpers import cookies
 
 def determine(domain: str, headers: dict) -> dict:
index 397e63b2cebbe76311058b5e72a3661529d4e27b..b41e651134a676c8b1dd3d950228c047adf8a41c 100644 (file)
@@ -18,11 +18,11 @@ from urllib.parse import urlparse
 import bs4
 import validators
 
-from fba import config
 from fba import csrf
 from fba import network
 
 from fba.helpers import blacklist
+from fba.helpers import config
 from fba.helpers import tidyup
 from fba.helpers import version
 
index 473eed0a0773ceca4f0e5da95c1bfb2d8084449a..b332baef0fe1f4ee65d74c2851a1aa079f7108f0 100644 (file)
@@ -16,6 +16,7 @@
 __all__ = [
     'blacklist',
     'cache',
+    'config',
     'cookies',
     'dicts',
     'locking',
diff --git a/fba/helpers/config.py b/fba/helpers/config.py
new file mode 100644 (file)
index 0000000..1ae1a25
--- /dev/null
@@ -0,0 +1,33 @@
+# Fedi API Block - An aggregator for fetching blocking data from fediverse nodes
+# Copyright (C) 2023 Free Software Foundation
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# 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/>.
+
+import json
+
+with open("config.json") as f:
+    # DEBUG: print("DEBUG: Loading configuration file ...")
+    _config = json.loads(f.read())
+
+def get(key: str) -> any:
+    # DEBUG: print(f"DEBUG: key[{type(key)}]={key} - CALLED!")
+    if not isinstance(key, str):
+        raise ValueError(f"Parameter key[]='{type(key)}' is not 'str'")
+    elif key == "":
+        raise ValueError("Parameter 'key' is empty")
+    elif not key in _config:
+        raise KeyError(f"key='{key}' does not exist in _config array")
+
+    # DEBUG: print(f"DEBUG: _config[{key}]={_config[key]} - EXIT!")
+    return _config[key]
index 6602406785960601dca0f042eb8f556391e60116..68c5407a1b2644329296ad883285fb29d4ce3c15 100644 (file)
 import json
 import time
 
-from fba import config
 from fba import fba
 
+from fba.helpers import config
+
 def add(domain: str, error: dict):
     # DEBUG: print("DEBUG: domain,error[]:", domain, type(error))
     if not isinstance(domain, str):
index 83402e72051ca5c68c19bd461564fc1787060a6e..ecb5454f4a671f0d70ad1b84e1caaa2f4ed5f307 100644 (file)
@@ -20,13 +20,13 @@ import time
 import requests
 import validators
 
-from fba import config
 from fba import fba
 from fba import federation
 from fba import network
 
 from fba.helpers import blacklist
 from fba.helpers import cache
+from fba.helpers import config
 
 from fba.models import error_log
 
index 79ac8f7b03bb4fc6d2abc91b43b6be5b66cf1f12..33ae3c69e0efd6f4a63902532c2df648065ec97f 100644 (file)
@@ -20,9 +20,9 @@ import requests
 import urllib3
 import validators
 
-from fba import config
 from fba import fba
 
+from fba.helpers import config
 from fba.helpers import cookies
 
 from fba.models import instances
index e6138c74deabeeeb00e85c07a8ed113fb667e59e..1ebd0a0098e80cda780afe4c89067d6c8d9800f2 100644 (file)
 import bs4
 import validators
 
-from fba import config
 from fba import network
 
 from fba.helpers import blacklist
+from fba.helpers import config
 from fba.helpers import tidyup
 
 from fba.models import instances
index e8ca1e1adb1322afc7011f9d47be576d3c5d22d2..cf44f424e27c4f4172a574a3af63bf68f67214b6 100644 (file)
@@ -19,13 +19,13 @@ import inspect
 import bs4
 import validators
 
-from fba import config
 from fba import csrf
 from fba import fba
 from fba import federation
 from fba import network
 
 from fba.helpers import blacklist
+from fba.helpers import config
 from fba.helpers import tidyup
 
 from fba.models import blocks
index 9aeec1bf087415674c823dac526ecf08a194f5c3..29718a05d68953d03b135fba4f7f3bb8ecb6f939 100644 (file)
@@ -19,12 +19,12 @@ import inspect
 import bs4
 import validators
 
-from fba import config
 from fba import csrf
 from fba import fba
 from fba import network
 
 from fba.helpers import blacklist
+from fba.helpers import config
 from fba.helpers import tidyup
 
 from fba.models import blocks
index 3b93b542eaf76ac7714c21c8570e1e517fe83078..ff5da395c3ae74cd2058cfa87129327d4bd7c4cf 100644 (file)
 
 import json
 
-from fba import config
 from fba import csrf
 from fba import network
 
 from fba.helpers import blacklist
+from fba.helpers import config
 from fba.helpers import dicts
 from fba.helpers import tidyup
 
index f63064283a2625052d1891ebe08c2e014b9cc9f1..13672ea22cdb842c821af9b5cb8b9453887f9c0c 100644 (file)
 # 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 fba import config
 from fba import csrf
 from fba import network
 
+from fba.helpers import config
+
 from fba.models import instances
 
 def fetch_peers(domain: str) -> list:
index 75dfd2bb8dc733ed65cc49a8916faa89ec93ef03..f82575e20903741507c11530ddde4b2455da57a7 100644 (file)
@@ -19,12 +19,12 @@ import inspect
 import bs4
 import validators
 
-from fba import config
 from fba import fba
 from fba import federation
 from fba import network
 
 from fba.helpers import blacklist
+from fba.helpers import config
 from fba.helpers import tidyup
 
 from fba.models import blocks