.oO SearXNG Developer Documentation Oo.
|
Classes | |
class | CSVWriter |
class | JSONEncoder |
Functions | |
get_translated_errors (Iterable[UnresponsiveEngine] unresponsive_engines) | |
None | write_csv_response (CSVWriter csv, ResultContainer rc) |
str | get_json_response (SearchQuery sq, ResultContainer rc) |
get_themes (templates_path) | |
str | get_hash_for_file (pathlib.Path file) |
Dict[str, str] | get_static_files (str static_path) |
get_result_templates (templates_path) | |
new_hmac (secret_key, url) | |
is_hmac_of (secret_key, value, hmac_to_check) | |
prettify_url (url, max_length=74) | |
bool | contains_cjko (str s) |
str | regex_highlight_cjk (str word) |
highlight_content (content, query) | |
str | searxng_l10n_timespan (datetime dt) |
is_flask_run_cmdline () | |
List[Tuple[str, Iterable[Engine]]] | group_engines_in_tab (Iterable[Engine] engines) |
Variables | |
VALID_LANGUAGE_CODE = re.compile(r'^[a-z]{2,3}(-[a-zA-Z]{2})?$') | |
logger = logger.getChild('webutils') | |
timeout_text = gettext('timeout') | |
parsing_error_text = gettext('parsing error') | |
http_protocol_error_text = gettext('HTTP protocol error') | |
network_error_text = gettext('network error') | |
ssl_cert_error_text = gettext("SSL error: certificate validation has failed") | |
dict | exception_classname_to_text |
str | NO_SUBGROUPING = 'without further subgrouping' |
bool searx.webutils.contains_cjko | ( | str | s | ) |
This function check whether or not a string contains Chinese, Japanese, or Korean characters. It employs regex and uses the u escape sequence to match any character in a set of Unicode ranges. Args: s (str): string to be checked. Returns: bool: True if the input s contains the characters and False otherwise.
Definition at line 234 of file webutils.py.
Referenced by searx.webutils.regex_highlight_cjk().
str searx.webutils.get_hash_for_file | ( | pathlib.Path | file | ) |
Definition at line 181 of file webutils.py.
Referenced by searx.webutils.get_static_files().
str searx.webutils.get_json_response | ( | SearchQuery | sq, |
ResultContainer | rc ) |
Returns the JSON string of the results to a query (``application/json``)
Definition at line 159 of file webutils.py.
References searx.webutils.get_translated_errors().
searx.webutils.get_result_templates | ( | templates_path | ) |
Definition at line 207 of file webutils.py.
Dict[str, str] searx.webutils.get_static_files | ( | str | static_path | ) |
Definition at line 188 of file webutils.py.
References searx.webutils.get_hash_for_file().
searx.webutils.get_themes | ( | templates_path | ) |
Returns available themes list.
Definition at line 176 of file webutils.py.
searx.webutils.get_translated_errors | ( | Iterable[UnresponsiveEngine] | unresponsive_engines | ) |
Definition at line 70 of file webutils.py.
Referenced by searx.webutils.get_json_response().
Groups an Iterable of engines by their first non tab category (first subgroup)
Definition at line 337 of file webutils.py.
searx.webutils.highlight_content | ( | content, | |
query ) |
Definition at line 276 of file webutils.py.
References searx.webutils.regex_highlight_cjk().
searx.webutils.is_flask_run_cmdline | ( | ) |
Check if the application was started using "flask run" command line Inspect the callstack. See https://github.com/pallets/flask/blob/master/src/flask/__main__.py Returns: bool: True if the application was started using "flask run".
Definition at line 319 of file webutils.py.
searx.webutils.is_hmac_of | ( | secret_key, | |
value, | |||
hmac_to_check ) |
Definition at line 222 of file webutils.py.
searx.webutils.new_hmac | ( | secret_key, | |
url ) |
Definition at line 218 of file webutils.py.
searx.webutils.prettify_url | ( | url, | |
max_length = 74 ) |
Definition at line 227 of file webutils.py.
References searx.format.
str searx.webutils.regex_highlight_cjk | ( | str | word | ) |
Generate the regex pattern to match for a given word according to whether or not the word contains CJK characters or not. If the word is and/or contains CJK character, the regex pattern will match standalone word by taking into account the presence of whitespace before and after it; if not, it will match any presence of the word throughout the text, ignoring the whitespace. Args: word (str): the word to be matched with regex pattern. Returns: str: the regex pattern for the word.
Definition at line 256 of file webutils.py.
References searx.webutils.contains_cjko().
Referenced by searx.webutils.highlight_content().
str searx.webutils.searxng_l10n_timespan | ( | datetime | dt | ) |
Returns a human-readable and translated string indicating how long ago a date was in the past / the time span of the date to the present. On January 1st, midnight, the returned string only indicates how many years ago the date was.
Definition at line 297 of file webutils.py.
References searx.format.
None searx.webutils.write_csv_response | ( | CSVWriter | csv, |
ResultContainer | rc ) |
Write rows of the results to a query (``application/csv``) into a CSV table (:py:obj:`CSVWriter`). First line in the table contain the column names. The column "type" specifies the type, the following types are included in the table: - result - answer - suggestion - correction
Definition at line 113 of file webutils.py.
dict searx.webutils.exception_classname_to_text |
Definition at line 41 of file webutils.py.
searx.webutils.http_protocol_error_text = gettext('HTTP protocol error') |
Definition at line 38 of file webutils.py.
searx.webutils.logger = logger.getChild('webutils') |
Definition at line 34 of file webutils.py.
searx.webutils.network_error_text = gettext('network error') |
Definition at line 39 of file webutils.py.
str searx.webutils.NO_SUBGROUPING = 'without further subgrouping' |
Definition at line 334 of file webutils.py.
searx.webutils.parsing_error_text = gettext('parsing error') |
Definition at line 37 of file webutils.py.
searx.webutils.ssl_cert_error_text = gettext("SSL error: certificate validation has failed") |
Definition at line 40 of file webutils.py.
searx.webutils.timeout_text = gettext('timeout') |
Definition at line 36 of file webutils.py.
searx.webutils.VALID_LANGUAGE_CODE = re.compile(r'^[a-z]{2,3}(-[a-zA-Z]{2})?$') |
Definition at line 32 of file webutils.py.