.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
4There is a command line for developer purposes and for deeper analysis. Here is
5an example in which the command line is called in the development environment::
6
7 $ ./manage pyenv.cmd bash --norc --noprofile
8 (py3) python -m searx.favicons --help
9"""
10
11
12__all__ = ["init", "favicon_url", "favicon_proxy"]
13
14import pathlib
15from searx import logger
16from searx import get_setting
17from .proxy import favicon_url, favicon_proxy
18
19logger = logger.getChild('favicons')
20
21
23 return bool(get_setting("search.favicon_resolver", False))
24
25
26def init():
27
28 # pylint: disable=import-outside-toplevel
29
30 from . import config, cache, proxy
31 from .. import settings_loader
32
33 cfg_file = (settings_loader.get_user_cfg_folder() or pathlib.Path("/etc/searxng")) / "favicons.toml"
34 if not cfg_file.exists():
35 if is_active():
36 logger.error(f"missing favicon config: {cfg_file}")
37 cfg_file = config.DEFAULT_CFG_TOML_PATH
38
39 logger.debug(f"load favicon config: {cfg_file}")
40 cfg = config.FaviconConfig.from_toml_file(cfg_file, use_cache=True)
41 cache.init(cfg.cache)
42 proxy.init(cfg.proxy)
43
44 del cache, config, proxy, cfg, settings_loader
t.Any get_setting(str name, t.Any default=_unset)
Definition __init__.py:74