Fix some code style

Please, people, adhere to our code style.
This commit is contained in:
Ghostkeeper 2019-02-08 11:01:09 +01:00
parent 2519ad311b
commit eb3129815d
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276
2 changed files with 15 additions and 14 deletions

View file

@ -1,5 +1,6 @@
# Copyright (c) 2018 Ultimaker B.V. # Copyright (c) 2019 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
from typing import Optional, Callable, Tuple, Dict, Any, List, TYPE_CHECKING from typing import Optional, Callable, Tuple, Dict, Any, List, TYPE_CHECKING
from http.server import BaseHTTPRequestHandler from http.server import BaseHTTPRequestHandler
@ -60,30 +61,30 @@ class AuthorizationRequestHandler(BaseHTTPRequestHandler):
elif self._queryGet(query, "error_code") == "user_denied": elif self._queryGet(query, "error_code") == "user_denied":
# Otherwise we show an error message (probably the user clicked "Deny" in the auth dialog). # Otherwise we show an error message (probably the user clicked "Deny" in the auth dialog).
token_response = AuthenticationResponse( token_response = AuthenticationResponse(
success=False, success = False,
err_message="Please give the required permissions when authorizing this application." err_message = "Please give the required permissions when authorizing this application."
) )
else: else:
# We don't know what went wrong here, so instruct the user to check the logs. # We don't know what went wrong here, so instruct the user to check the logs.
token_response = AuthenticationResponse( token_response = AuthenticationResponse(
success=False, success = False,
error_message="Something unexpected happened when trying to log in, please try again." error_message = "Something unexpected happened when trying to log in, please try again."
) )
if self.authorization_helpers is None: if self.authorization_helpers is None:
return ResponseData(), token_response return ResponseData(), token_response
return ResponseData( return ResponseData(
status=HTTP_STATUS["REDIRECT"], status = HTTP_STATUS["REDIRECT"],
data_stream=b"Redirecting...", data_stream = b"Redirecting...",
redirect_uri=self.authorization_helpers.settings.AUTH_SUCCESS_REDIRECT if token_response.success else redirect_uri = self.authorization_helpers.settings.AUTH_SUCCESS_REDIRECT if token_response.success else
self.authorization_helpers.settings.AUTH_FAILED_REDIRECT self.authorization_helpers.settings.AUTH_FAILED_REDIRECT
), token_response ), token_response
@staticmethod @staticmethod
# Handle all other non-existing server calls. # Handle all other non-existing server calls.
def _handleNotFound() -> ResponseData: def _handleNotFound() -> ResponseData:
return ResponseData(status=HTTP_STATUS["NOT_FOUND"], content_type="text/html", data_stream=b"Not found.") return ResponseData(status = HTTP_STATUS["NOT_FOUND"], content_type = "text/html", data_stream = b"Not found.")
def _sendHeaders(self, status: "ResponseStatus", content_type: str, redirect_uri: str = None) -> None: def _sendHeaders(self, status: "ResponseStatus", content_type: str, redirect_uri: str = None) -> None:
self.send_response(status.code, status.message) self.send_response(status.code, status.message)
@ -97,5 +98,5 @@ class AuthorizationRequestHandler(BaseHTTPRequestHandler):
@staticmethod @staticmethod
# Convenience Helper for getting values from a pre-parsed query string # Convenience Helper for getting values from a pre-parsed query string
def _queryGet(query_data: Dict[Any, List], key: str, default: Optional[str]=None) -> Optional[str]: def _queryGet(query_data: Dict[Any, List], key: str, default: Optional[str] = None) -> Optional[str]:
return query_data.get(key, [default])[0] return query_data.get(key, [default])[0]

View file

@ -1,4 +1,4 @@
# Copyright (c) 2018 Ultimaker B.V. # Copyright (c) 2019 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
from typing import Optional from typing import Optional
@ -56,7 +56,7 @@ class ResponseData(BaseModel):
# Possible HTTP responses. # Possible HTTP responses.
HTTP_STATUS = { HTTP_STATUS = {
"OK": ResponseStatus(code=200, message="OK"), "OK": ResponseStatus(code = 200, message = "OK"),
"NOT_FOUND": ResponseStatus(code=404, message="NOT FOUND"), "NOT_FOUND": ResponseStatus(code = 404, message = "NOT FOUND"),
"REDIRECT": ResponseStatus(code=302, message="REDIRECT") "REDIRECT": ResponseStatus(code = 302, message = "REDIRECT")
} }