[breaking change] drop deprecated hostname_replace plugin
The successor is “hostname plugin” from PR:
- https://github.com/searxng/searxng/pull/3463
---
Revert "[refactor] hostnames plugin: add fallback for old hostname_replace plugin"
This reverts commit f5eb56b63f.
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
			
			
This commit is contained in:
		
							parent
							
								
									0cfed94b08
								
							
						
					
					
						commit
						dcf95644c6
					
				| @ -1,35 +0,0 @@ | |||||||
| # SPDX-License-Identifier: AGPL-3.0-or-later |  | ||||||
| # pylint: disable=missing-module-docstring |  | ||||||
| 
 |  | ||||||
| from flask_babel import gettext |  | ||||||
| from searx.plugins import logger |  | ||||||
| 
 |  | ||||||
| name = gettext('Hostname replace') |  | ||||||
| description = "Deprecated / contact system admin to configure 'Hostnames plugin'!!" |  | ||||||
| default_on = False |  | ||||||
| preference_section = 'general' |  | ||||||
| 
 |  | ||||||
| plugin_id = 'hostname_replace' |  | ||||||
| logger = logger.getChild(plugin_id) |  | ||||||
| 
 |  | ||||||
| REPORTED = False |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| def deprecated_msg(): |  | ||||||
|     global REPORTED  # pylint: disable=global-statement |  | ||||||
|     if REPORTED: |  | ||||||
|         return |  | ||||||
|     logger.error( |  | ||||||
|         "'Hostname replace' plugin is deprecated and will be dropped soon!" |  | ||||||
|         " Configure 'Hostnames plugin':" |  | ||||||
|         " https://docs.searxng.org/src/searx.plugins.hostnames.html" |  | ||||||
|     ) |  | ||||||
|     REPORTED = True |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| def on_result(_request, _search, result): |  | ||||||
|     # pylint: disable=import-outside-toplevel, cyclic-import |  | ||||||
|     from searx.plugins.hostnames import on_result as hostnames_on_result |  | ||||||
| 
 |  | ||||||
|     deprecated_msg() |  | ||||||
|     return hostnames_on_result(_request, _search, result) |  | ||||||
| @ -3,16 +3,6 @@ | |||||||
| """In addition to rewriting/replace reslut URLs, the *hoostnames* plugin offers | """In addition to rewriting/replace reslut URLs, the *hoostnames* plugin offers | ||||||
| other features. | other features. | ||||||
| 
 | 
 | ||||||
| .. attention:: |  | ||||||
| 
 |  | ||||||
|    The 'Hostnames plugin' from `PR-3463 |  | ||||||
|    <https://github.com/searxng/searxng/pull/3463>`_ is a rewrite of the |  | ||||||
|    'Hostname replace' plugin.  Backwards compatibility is guaranteed for a |  | ||||||
|    transitional period, but this will end soon. |  | ||||||
| 
 |  | ||||||
|    **To maintainers of SearXNG instances, please modify your old plugin config |  | ||||||
|    to the new.** |  | ||||||
| 
 |  | ||||||
| - ``hostnames.replace``: A **mapping** of regular expressions to hostnames to be | - ``hostnames.replace``: A **mapping** of regular expressions to hostnames to be | ||||||
|   replaced by other hostnames. |   replaced by other hostnames. | ||||||
| 
 | 
 | ||||||
| @ -129,29 +119,8 @@ def _load_regular_expressions(settings_key): | |||||||
|     return {} |     return {} | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| # compatibility fallback for old hostname replace plugin | replacements = _load_regular_expressions('replace') | ||||||
| # TODO: remove in the future once most/all instance maintainers finished migrating # pylint: disable=fixme | removables = _load_regular_expressions('remove') | ||||||
| def _load_regular_expressions_with_fallback(settings_key): |  | ||||||
|     expressions = _load_regular_expressions(settings_key) |  | ||||||
|     if expressions: |  | ||||||
|         return expressions |  | ||||||
| 
 |  | ||||||
|     # fallback to the old `hostname_replace` settings format |  | ||||||
|     # pylint: disable=import-outside-toplevel, cyclic-import |  | ||||||
|     hostname_replace_config = settings.get('hostname_replace', {}) |  | ||||||
|     if hostname_replace_config: |  | ||||||
|         from searx.plugins.hostname_replace import deprecated_msg |  | ||||||
| 
 |  | ||||||
|         deprecated_msg() |  | ||||||
| 
 |  | ||||||
|     if settings_key == 'replace': |  | ||||||
|         return {re.compile(p): r for (p, r) in hostname_replace_config.items() if r} |  | ||||||
| 
 |  | ||||||
|     return {re.compile(p) for (p, r) in hostname_replace_config.items() if not r} |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| replacements = _load_regular_expressions_with_fallback('replace') |  | ||||||
| removables = _load_regular_expressions_with_fallback('remove') |  | ||||||
| high_priority = _load_regular_expressions('high_priority') | high_priority = _load_regular_expressions('high_priority') | ||||||
| low_priority = _load_regular_expressions('low_priority') | low_priority = _load_regular_expressions('low_priority') | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user