Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions packit_service/service/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

def response_maker(result: Any, status: HTTPStatus = HTTPStatus.OK):
"""response_maker is a wrapper around flask's make_response"""
"""This function uses Jsonify and directly sets the status code than being a wrapper to it """
resp = jsonify(result)
resp.status_code = status.value
return resp
Expand Down Expand Up @@ -108,11 +109,15 @@ def get_sync_release_info(sync_release_model: SyncReleaseModel):


def get_project_info(project: Union[AnityaProjectModel, GitProjectModel]):
result_dict = {}

anitya_project_id = anitya_project_name = anitya_package = None
project_url = repo_name = repo_namespace = None

"""Changed result_dict={} --> result_dict=dict()

This is to avoid none values in the result dictionary"""
result_dict = dict()
"""change multiple line none value declaration to single line none value declaration for better readability"""
anitya_project_id = anitya_project_name = anitya_package = project_url = repo_name = repo_namespace = None

"""return "" (empty string) if project is none """

if isinstance(project, AnityaProjectModel):
anitya_project_id = project.project_id if project else ""
anitya_project_name = project.project_name if project else ""
Expand Down