mirror of
https://github.com/searxng/searxng
synced 2024-10-30 21:20:28 +00:00
ed66ed758d
babel.Locale.parse loads more than 60MB in RAM. The only purpose is to get: LOCALE_NAMES - searx.data.LOCALES["LOCALE_NAMES"] RTL_LOCALES - searx.data.LOCALES["RTL_LOCALES"] This commit calls babel.Locale.parse when the translations are update from weblate and stored in:: searx/data/locales.json This file can be build by:: ./manage data.locales By store these variables in searx.data when the translations are updated we save round about 65MB (usually 4 worker = 260MB of RAM saved. Suggested-by: https://github.com/searxng/searxng/discussions/2633#discussioncomment-8490494 Co-authored-by: Markus Heiser <markus.heiser@darmarit.de>
55 lines
1.3 KiB
Python
55 lines
1.3 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
# lint: pylint
|
|
"""This module holds the *data* created by::
|
|
|
|
make data.all
|
|
|
|
"""
|
|
|
|
__all__ = [
|
|
'ENGINE_TRAITS',
|
|
'CURRENCIES',
|
|
'USER_AGENTS',
|
|
'EXTERNAL_URLS',
|
|
'WIKIDATA_UNITS',
|
|
'EXTERNAL_BANGS',
|
|
'OSM_KEYS_TAGS',
|
|
'ENGINE_DESCRIPTIONS',
|
|
'LOCALES',
|
|
'ahmia_blacklist_loader',
|
|
]
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
data_dir = Path(__file__).parent
|
|
|
|
|
|
def _load(filename):
|
|
with open(data_dir / filename, encoding='utf-8') as f:
|
|
return json.load(f)
|
|
|
|
|
|
def ahmia_blacklist_loader():
|
|
"""Load data from `ahmia_blacklist.txt` and return a list of MD5 values of onion
|
|
names. The MD5 values are fetched by::
|
|
|
|
searxng_extra/update/update_ahmia_blacklist.py
|
|
|
|
This function is used by :py:mod:`searx.plugins.ahmia_filter`.
|
|
|
|
"""
|
|
with open(data_dir / 'ahmia_blacklist.txt', encoding='utf-8') as f:
|
|
return f.read().split()
|
|
|
|
|
|
CURRENCIES = _load('currencies.json')
|
|
USER_AGENTS = _load('useragents.json')
|
|
EXTERNAL_URLS = _load('external_urls.json')
|
|
WIKIDATA_UNITS = _load('wikidata_units.json')
|
|
EXTERNAL_BANGS = _load('external_bangs.json')
|
|
OSM_KEYS_TAGS = _load('osm_keys_tags.json')
|
|
ENGINE_DESCRIPTIONS = _load('engine_descriptions.json')
|
|
ENGINE_TRAITS = _load('engine_traits.json')
|
|
LOCALES = _load('locales.json')
|