summaryrefslogtreecommitdiff
path: root/searx/data
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2020-10-05 13:50:33 +0200
committerAlexandre Flament <alex@al-f.net>2020-10-07 10:29:34 +0200
commita9dc54bebc943000252975ef25ddcb51681fc284 (patch)
tree1cf83faca105df629ea06a3492884001d6b4d84c /searx/data
parente30dc2f0ba481e033f127e5619d90cdc05d6db25 (diff)
downloadsearxng-a9dc54bebc943000252975ef25ddcb51681fc284.tar.gz
searxng-a9dc54bebc943000252975ef25ddcb51681fc284.zip
[mod] Add searx.data module
Instead of loading the data/*.json in different location, load these files in the new searx.data module.
Diffstat (limited to 'searx/data')
-rw-r--r--searx/data/__init__.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/searx/data/__init__.py b/searx/data/__init__.py
new file mode 100644
index 000000000..391947bff
--- /dev/null
+++ b/searx/data/__init__.py
@@ -0,0 +1,21 @@
+import json
+from pathlib import Path
+
+
+__init__ = ['ENGINES_LANGUGAGES', 'CURRENCIES', 'USER_AGENTS', 'bangs_loader']
+data_dir = Path(__file__).parent
+
+
+def load(filename):
+ # add str(...) for Python 3.5
+ with open(str(data_dir / filename), encoding='utf-8') as fd:
+ return json.load(fd)
+
+
+def bangs_loader():
+ return load('bangs.json')
+
+
+ENGINES_LANGUAGES = load('engines_languages.json')
+CURRENCIES = load('currencies.json')
+USER_AGENTS = load('useragents.json')