diff --git a/src/somef/parser/codemeta_parser.py b/src/somef/parser/codemeta_parser.py index eb5fb8e0..f69afa70 100644 --- a/src/somef/parser/codemeta_parser.py +++ b/src/somef/parser/codemeta_parser.py @@ -852,7 +852,7 @@ def map_reference_publication(pub_data): if isinstance(a, dict) ] - result["authors"] = mapped_authors + result[constants.CAT_AUTHORS] = mapped_authors return result diff --git a/src/somef/process_repository.py b/src/somef/process_repository.py index 064d548c..d6eb5841 100644 --- a/src/somef/process_repository.py +++ b/src/somef/process_repository.py @@ -247,12 +247,12 @@ def load_gitlab_repository_metadata(repo_metadata: Result, repository_url, autho encoded_project_path = quote(project_path, safe="") # Codifica "/" como "%2F" # Build url of api to get id api_url = f"https://{url.netloc}/api/v4/projects/{encoded_project_path}" - project_id = get_project_id(api_url, True, authorization) + project_id = get_project_id(api_url, True, authorization,use_config=False) logging.info(f'Project_id: {project_id}') project_api_url = f"https://{url.netloc}/api/v4/projects/{project_id}" logging.info(f"Downloading {project_api_url}") - details, date = rate_limit_get(project_api_url, headers=gitlab_header_template(authorization)) + details, date = rate_limit_get(project_api_url, headers=gitlab_header_template(authorization, use_config=False)) project_details = details.json() # date = details.headers["date"] @@ -1017,7 +1017,7 @@ def download_github_files(directory, owner, repo_name, repo_ref, authorization, return repo_dir -def get_project_id(repository_url,self_hosted, authorization=None): +def get_project_id(repository_url,self_hosted, authorization=None, use_config=True): """ Function to download a repository, given its URL Parameters: @@ -1029,7 +1029,7 @@ def get_project_id(repository_url,self_hosted, authorization=None): logging.info(f"Downloading {repository_url}") # response = requests.get(repository_url) - headers = gitlab_header_template(authorization) + headers = gitlab_header_template(authorization, use_config=use_config) response = requests.get(repository_url, headers=headers) project_id = "-1" @@ -1383,13 +1383,13 @@ def download_codeberg_files(directory, owner, repo_name, repo_branch, authorizat return repo_dir -def gitlab_header_template(authorization=None): +def gitlab_header_template(authorization=None, use_config=True): header = {} file_paths = configuration.get_configuration_file() if authorization is not None: header[constants.PROP_AUTHORIZATION] = authorization logging.info("GitLab: using authorization token passed directly") - elif constants.CONF_GITLAB_AUTHORIZATION in file_paths: + elif use_config and constants.CONF_GITLAB_AUTHORIZATION in file_paths: header[constants.PROP_AUTHORIZATION] = file_paths[constants.CONF_GITLAB_AUTHORIZATION] logging.info("GitLab: authorization token found in config") return header diff --git a/src/somef/test/test_codemeta_parser.py b/src/somef/test/test_codemeta_parser.py index 3b3d0b00..5f906ffb 100644 --- a/src/somef/test/test_codemeta_parser.py +++ b/src/somef/test/test_codemeta_parser.py @@ -131,12 +131,12 @@ def test_parse_reference_publications_authors_issue_957(self): found = False for cit in citations: - authors = cit["result"].get("authors", []) + authors = cit["result"].get(constants.CAT_AUTHORS, []) if any(a.get("name") == "Daniel Garijo" and a.get("family_name") == "Garijo" and a.get("given_name") == "Daniel" for a in authors): found = True break - self.assertTrue(found, "Author 'Daniel Garijo' with 'given_name' not found in citation authors") + self.assertTrue(found, "Author 'Daniel Garijo' with 'given_name' not found in citation author") if __name__ == "__main__": diff --git a/src/somef/utils/constants.py b/src/somef/utils/constants.py index 96e14686..12e19eab 100644 --- a/src/somef/utils/constants.py +++ b/src/somef/utils/constants.py @@ -396,7 +396,7 @@ CAT_DESCRIPTION: "description", CAT_DATE_CREATED: "created_on", CAT_DATE_UPDATED: "updated_on", - CAT_OWNER: ["owner", "nickname"], + CAT_OWNER: ["owner", "username"], CAT_CODE_REPOSITORY: ["links", "html", "href"], CAT_HOMEPAGE: "website", CAT_FORKS_URLS: ["links", "forks", "href"]