.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.search.processors Namespace Reference

Namespaces

namespace  abstract
namespace  offline
namespace  online
namespace  online_currency
namespace  online_dictionary
namespace  online_url_search

Functions

type[EngineProcessor]|None get_processor_class (str engine_type)
EngineProcessor|None get_processor ("Engine | ModuleType" engine, str engine_name)
 initialize_processor (EngineProcessor processor)
 initialize (list[dict[str, t.Any]] engine_list)

Variables

list __all__
 logger = logger.getChild('search.processors')
dict PROCESSORS = {}

Detailed Description

Implement request processors used by engine-types.

Function Documentation

◆ get_processor()

EngineProcessor | None searx.search.processors.get_processor ( "Engine | ModuleType" engine,
str engine_name )
Return processor instance that fits to ``engine.engine.type``

Definition at line 53 of file __init__.py.

53def get_processor(engine: "Engine | ModuleType", engine_name: str) -> EngineProcessor | None:
54 """Return processor instance that fits to ``engine.engine.type``"""
55 engine_type = getattr(engine, 'engine_type', 'online')
56 processor_class = get_processor_class(engine_type)
57 if processor_class is not None:
58 return processor_class(engine, engine_name)
59 return None
60
61

References get_processor_class().

Referenced by initialize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_processor_class()

type[EngineProcessor] | None searx.search.processors.get_processor_class ( str engine_type)
Return processor class according to the ``engine_type``

Definition at line 39 of file __init__.py.

39def get_processor_class(engine_type: str) -> type[EngineProcessor] | None:
40 """Return processor class according to the ``engine_type``"""
41 for c in [
42 OnlineProcessor,
43 OfflineProcessor,
44 OnlineDictionaryProcessor,
45 OnlineCurrencyProcessor,
46 OnlineUrlSearchProcessor,
47 ]:
48 if c.engine_type == engine_type:
49 return c
50 return None
51
52

Referenced by get_processor().

Here is the caller graph for this function:

◆ initialize()

searx.search.processors.initialize ( list[dict[str, t.Any]] engine_list)
Initialize all engines and store a processor for each engine in
:py:obj:`PROCESSORS`.

Definition at line 72 of file __init__.py.

72def initialize(engine_list: list[dict[str, t.Any]]):
73 """Initialize all engines and store a processor for each engine in
74 :py:obj:`PROCESSORS`."""
75 for engine_data in engine_list:
76 engine_name: str = engine_data['name']
77 engine = engines.engines.get(engine_name)
78 if engine:
79 processor = get_processor(engine, engine_name)
80 if processor is None:
81 engine.logger.error('Error get processor for engine %s', engine_name)
82 else:
83 initialize_processor(processor)
84 PROCESSORS[engine_name] = processor

References get_processor(), and initialize_processor().

Here is the call graph for this function:

◆ initialize_processor()

searx.search.processors.initialize_processor ( EngineProcessor processor)
Initialize one processor

Call the init function of the engine

Definition at line 62 of file __init__.py.

62def initialize_processor(processor: EngineProcessor):
63 """Initialize one processor
64
65 Call the init function of the engine
66 """
67 if processor.has_initialize_function:
68 _t = threading.Thread(target=processor.initialize, daemon=True)
69 _t.start()
70
71

Referenced by initialize().

Here is the caller graph for this function:

Variable Documentation

◆ __all__

list searx.search.processors.__all__
private
Initial value:
1= [
2 'EngineProcessor',
3 'OfflineProcessor',
4 'OnlineProcessor',
5 'OnlineDictionaryProcessor',
6 'OnlineCurrencyProcessor',
7 'OnlineUrlSearchProcessor',
8 'PROCESSORS',
9]

Definition at line 4 of file __init__.py.

◆ logger

searx.search.processors.logger = logger.getChild('search.processors')

Definition at line 31 of file __init__.py.

◆ PROCESSORS

dict searx.search.processors.PROCESSORS = {}

Definition at line 32 of file __init__.py.