mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
[mod] Add searx.data module
Instead of loading the data/*.json in different location, load these files in the new searx.data module.
This commit is contained in:
parent
e30dc2f0ba
commit
a9dc54bebc
5 changed files with 37 additions and 41 deletions
21
searx/data/__init__.py
Normal file
21
searx/data/__init__.py
Normal file
|
|
@ -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')
|
||||
Loading…
Add table
Add a link
Reference in a new issue