Skip to content

Commit

Permalink
Linting, copying yoda-portal linting style
Browse files Browse the repository at this point in the history
  • Loading branch information
claravox committed Dec 11, 2023
1 parent b2ea97b commit f36a6c8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
ignore=E501
ignore=E221,E241,E402,W503,W605,F403,F405
import-order-style=smarkets
strictness=short
docstring_style=sphinx
Expand Down
25 changes: 20 additions & 5 deletions yoda_eus/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,10 @@ def process_forgot_password() -> Response:
return response

if (not is_email_valid(username) and app.config.get("MAIL_ONLY_TO_VALID_ADDRESS").lower() == "true"):
errors = {"errors": ["Unable to send password reset email, because your user name ('{}') is not a valid email address.".format(username)]}
errors = {
"errors": ["Unable to send password reset email, "
"because your user name ('{}') is not a valid email address.".format(username)]
}
response = make_response(render_template('forgot-password.html', **errors))
response.status_code = 404
return response
Expand Down Expand Up @@ -558,10 +561,14 @@ def refuse_api_requests() -> Response:
The EUS presents two web interfaces (vhosts) on two different TCP ports. One of these
does not have the API available, so that API access can be restricted on a TCP level (e.g. in firewalls).
If this instance does not have the API enabled, access to API functions is intercepted and blocked by this function.
If this instance does not have the API enabled, access to API functions is intercepted
and blocked by this function.
"""
if request.path.startswith("/api/"):
abort(make_response(jsonify({'status': 'error', 'message': 'The EUS API has been disabled on this interface.'}), 403))
abort(make_response(jsonify({
'status': 'error',
'message': 'The EUS API has been disabled on this interface.'
}), 403))

@app.before_request
def check_api_secret() -> Response:
Expand All @@ -576,7 +583,10 @@ def check_api_secret() -> Response:
elif secret_header in request.headers and request.headers[secret_header] == app.config.get("API_SECRET"):
return
else:
abort(make_response(jsonify({'status': 'error', 'message': 'EUS secret header not present or does not match.'}), 403))
abort(make_response(jsonify({
'status': 'error',
'message': 'EUS secret header not present or does not match.'
}), 403))

@app.before_request
def static_loader() -> Optional[Response]:
Expand All @@ -590,7 +600,12 @@ def static_loader() -> Optional[Response]:
:returns: Static file
"""
result = get_validated_static_path(request.full_path, request.path, app.config.get('YODA_THEME_PATH'), app.config.get('YODA_THEME'))
result = get_validated_static_path(
request.full_path,
request.path,
app.config.get('YODA_THEME_PATH'),
app.config.get('YODA_THEME')
)
if result is not None:
static_dir, asset_name = result
return send_from_directory(static_dir, asset_name)
Expand Down
3 changes: 2 additions & 1 deletion yoda_eus/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
__copyright__ = 'Copyright (c) 2021-2023, Utrecht University'
__license__ = 'GPLv3, see LICENSE'

from typing import Optional, Tuple
from os import path
from re import fullmatch
from typing import Optional, Tuple

from werkzeug.security import safe_join
from werkzeug.utils import secure_filename

Expand Down

0 comments on commit f36a6c8

Please sign in to comment.