.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
__init__.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2"""Implementations for providing the favicons in SearXNG"""
3
4from __future__ import annotations
5
6__all__ = ["init", "favicon_url", "favicon_proxy"]
7
8import pathlib
9from searx import logger
10from searx import get_setting
11from .proxy import favicon_url, favicon_proxy
12
13logger = logger.getChild('favicons')
14
15
17 return bool(get_setting("search.favicon_resolver", False))
18
19
20def init():
21
22 # pylint: disable=import-outside-toplevel
23
24 from . import config, cache, proxy
25 from .. import settings_loader
26
27 cfg_file = (settings_loader.get_user_cfg_folder() or pathlib.Path("/etc/searxng")) / "favicons.toml"
28 if not cfg_file.exists():
29 if is_active():
30 logger.error(f"missing favicon config: {cfg_file}")
31 cfg_file = config.DEFAULT_CFG_TOML_PATH
32
33 logger.debug(f"load favicon config: {cfg_file}")
34 cfg = config.FaviconConfig.from_toml_file(cfg_file, use_cache=True)
35 cache.init(cfg.cache)
36 proxy.init(cfg.proxy)
37
38 del cache, config, proxy, cfg, settings_loader