.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
11from __future__ import annotations
12
13__all__ = ["init", "favicon_url", "favicon_proxy"]
14
15import pathlib
16from searx import logger
17from searx import get_setting
18from .proxy import favicon_url, favicon_proxy
19
20logger = logger.getChild('favicons')
21
22
24 return bool(get_setting("search.favicon_resolver", False))
25
26
27def init():
28
29 # pylint: disable=import-outside-toplevel
30
31 from . import config, cache, proxy
32 from .. import settings_loader
33
34 cfg_file = (settings_loader.get_user_cfg_folder() or pathlib.Path("/etc/searxng")) / "favicons.toml"
35 if not cfg_file.exists():
36 if is_active():
37 logger.error(f"missing favicon config: {cfg_file}")
38 cfg_file = config.DEFAULT_CFG_TOML_PATH
39
40 logger.debug(f"load favicon config: {cfg_file}")
41 cfg = config.FaviconConfig.from_toml_file(cfg_file, use_cache=True)
42 cache.init(cfg.cache)
43 proxy.init(cfg.proxy)
44
45 del cache, config, proxy, cfg, settings_loader
get_setting(name, default=_unset)
Definition __init__.py:69