Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/somef/parser/codemeta_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

12 changes: 6 additions & 6 deletions src/somef/process_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down Expand Up @@ -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:
Expand All @@ -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"

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/somef/test/test_codemeta_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion src/somef/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
Loading