mirror of
https://github.com/searxng/searxng.git
synced 2024-11-14 00:30:15 +01:00
[fix] issues reported by pylint-3.2.2
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
e03c7e4dcd
commit
c19bffde4d
@ -80,8 +80,10 @@ def response(resp):
|
||||
|
||||
for entry in search_results.xpath('./result/doc'):
|
||||
content = "No description available"
|
||||
|
||||
url = ""
|
||||
title = ""
|
||||
date = datetime.now() # needed in case no dcdate is available for an item
|
||||
|
||||
for item in entry:
|
||||
if item.attrib["name"] == "dcdate":
|
||||
date = item.text
|
||||
|
@ -17,6 +17,8 @@ Usage in a Flask app route:
|
||||
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
__all__ = ['InfoPage', 'InfoPageSet']
|
||||
|
||||
import os
|
||||
@ -37,6 +39,16 @@ from ..locales import LOCALE_NAMES
|
||||
|
||||
logger = logging.getLogger('searx.infopage')
|
||||
_INFO_FOLDER = os.path.abspath(os.path.dirname(__file__))
|
||||
INFO_PAGES: 'InfoPageSet'
|
||||
|
||||
|
||||
def __getattr__(name):
|
||||
if name == 'INFO_PAGES':
|
||||
global INFO_PAGES # pylint: disable=global-statement
|
||||
INFO_PAGES = InfoPageSet()
|
||||
return INFO_PAGES
|
||||
|
||||
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
||||
|
||||
|
||||
class InfoPage:
|
||||
|
@ -276,8 +276,8 @@ def custom_url_for(endpoint: str, **values):
|
||||
suffix = "?" + file_hash
|
||||
if endpoint == 'info' and 'locale' not in values:
|
||||
locale = request.preferences.get_value('locale')
|
||||
if _INFO_PAGES.get_page(values['pagename'], locale) is None:
|
||||
locale = _INFO_PAGES.locale_default
|
||||
if infopage.INFO_PAGES.get_page(values['pagename'], locale) is None:
|
||||
locale = infopage.INFO_PAGES.locale_default
|
||||
values['locale'] = locale
|
||||
return url_for(endpoint, **values) + suffix
|
||||
|
||||
@ -804,14 +804,14 @@ def about():
|
||||
@app.route('/info/<locale>/<pagename>', methods=['GET'])
|
||||
def info(pagename, locale):
|
||||
"""Render page of online user documentation"""
|
||||
page = _INFO_PAGES.get_page(pagename, locale)
|
||||
page = infopage.INFO_PAGES.get_page(pagename, locale)
|
||||
if page is None:
|
||||
flask.abort(404)
|
||||
|
||||
user_locale = request.preferences.get_value('locale')
|
||||
return render(
|
||||
'info.html',
|
||||
all_pages=_INFO_PAGES.iter_pages(user_locale, fallback_to_default=True),
|
||||
all_pages=infopage.INFO_PAGES.iter_pages(user_locale, fallback_to_default=True),
|
||||
active_page=page,
|
||||
active_pagename=pagename,
|
||||
)
|
||||
@ -1333,7 +1333,6 @@ werkzeug_reloader = flask_run_development or (searx_debug and __name__ == "__mai
|
||||
# initialize the engines except on the first run of the werkzeug server.
|
||||
if not werkzeug_reloader or (werkzeug_reloader and os.environ.get("WERKZEUG_RUN_MAIN") == "true"):
|
||||
locales_initialize()
|
||||
_INFO_PAGES = infopage.InfoPageSet()
|
||||
redis_initialize()
|
||||
plugin_initialize(app)
|
||||
search_initialize(enable_checker=True, check_network=True, enable_metrics=settings['general']['enable_metrics'])
|
||||
|
Loading…
Reference in New Issue
Block a user