forked from Ponysearch/Ponysearch
[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
3 changed files with 19 additions and 6 deletions
|
@ -80,8 +80,10 @@ def response(resp):
|
||||||
|
|
||||||
for entry in search_results.xpath('./result/doc'):
|
for entry in search_results.xpath('./result/doc'):
|
||||||
content = "No description available"
|
content = "No description available"
|
||||||
|
url = ""
|
||||||
|
title = ""
|
||||||
date = datetime.now() # needed in case no dcdate is available for an item
|
date = datetime.now() # needed in case no dcdate is available for an item
|
||||||
|
|
||||||
for item in entry:
|
for item in entry:
|
||||||
if item.attrib["name"] == "dcdate":
|
if item.attrib["name"] == "dcdate":
|
||||||
date = item.text
|
date = item.text
|
||||||
|
|
|
@ -17,6 +17,8 @@ Usage in a Flask app route:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
__all__ = ['InfoPage', 'InfoPageSet']
|
__all__ = ['InfoPage', 'InfoPageSet']
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -37,6 +39,16 @@ from ..locales import LOCALE_NAMES
|
||||||
|
|
||||||
logger = logging.getLogger('searx.infopage')
|
logger = logging.getLogger('searx.infopage')
|
||||||
_INFO_FOLDER = os.path.abspath(os.path.dirname(__file__))
|
_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:
|
class InfoPage:
|
||||||
|
|
|
@ -276,8 +276,8 @@ def custom_url_for(endpoint: str, **values):
|
||||||
suffix = "?" + file_hash
|
suffix = "?" + file_hash
|
||||||
if endpoint == 'info' and 'locale' not in values:
|
if endpoint == 'info' and 'locale' not in values:
|
||||||
locale = request.preferences.get_value('locale')
|
locale = request.preferences.get_value('locale')
|
||||||
if _INFO_PAGES.get_page(values['pagename'], locale) is None:
|
if infopage.INFO_PAGES.get_page(values['pagename'], locale) is None:
|
||||||
locale = _INFO_PAGES.locale_default
|
locale = infopage.INFO_PAGES.locale_default
|
||||||
values['locale'] = locale
|
values['locale'] = locale
|
||||||
return url_for(endpoint, **values) + suffix
|
return url_for(endpoint, **values) + suffix
|
||||||
|
|
||||||
|
@ -804,14 +804,14 @@ def about():
|
||||||
@app.route('/info/<locale>/<pagename>', methods=['GET'])
|
@app.route('/info/<locale>/<pagename>', methods=['GET'])
|
||||||
def info(pagename, locale):
|
def info(pagename, locale):
|
||||||
"""Render page of online user documentation"""
|
"""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:
|
if page is None:
|
||||||
flask.abort(404)
|
flask.abort(404)
|
||||||
|
|
||||||
user_locale = request.preferences.get_value('locale')
|
user_locale = request.preferences.get_value('locale')
|
||||||
return render(
|
return render(
|
||||||
'info.html',
|
'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_page=page,
|
||||||
active_pagename=pagename,
|
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.
|
# 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"):
|
if not werkzeug_reloader or (werkzeug_reloader and os.environ.get("WERKZEUG_RUN_MAIN") == "true"):
|
||||||
locales_initialize()
|
locales_initialize()
|
||||||
_INFO_PAGES = infopage.InfoPageSet()
|
|
||||||
redis_initialize()
|
redis_initialize()
|
||||||
plugin_initialize(app)
|
plugin_initialize(app)
|
||||||
search_initialize(enable_checker=True, check_network=True, enable_metrics=settings['general']['enable_metrics'])
|
search_initialize(enable_checker=True, check_network=True, enable_metrics=settings['general']['enable_metrics'])
|
||||||
|
|
Loading…
Reference in a new issue