Skip to content

Commit

Permalink
chore: improve code in openaccess
Browse files Browse the repository at this point in the history
  • Loading branch information
utnapischtim committed Jan 7, 2025
1 parent 1100cde commit 7b69654
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 3 additions & 2 deletions invenio_workflows_tugraz/openaccess/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def license_type(electronic_version: dict) -> str:
return False


def extract_files(pure_record) -> URL:
def extract_files(pure_record: dict) -> URL:
"""Extract file url."""

def condition(item: dict) -> bool:
Expand All @@ -55,7 +55,8 @@ def condition(item: dict) -> bool:
continue

if len(files) == 0:
raise PureRuntimeError(pure_record)
msg = f"record: {pure_record["uuid"]} doesn't provide downloadable files"
raise RuntimeError(msg)

return files

Expand Down
6 changes: 2 additions & 4 deletions invenio_workflows_tugraz/openaccess/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
def openaccess_filter() -> dict:
"""Openaccess filter."""
return {
"keywordUris": ["dk/atira/pure/researchoutput/keywords/export2repo/validated"]
"keywordUris": ["dk/atira/pure/researchoutput/keywords/export2repo/validated"],
}


Expand All @@ -53,9 +53,7 @@ def import_func(
try:
pure_record = pure_service.get_metadata(identity, pure_id)
files = extract_files(pure_record)
file_paths = []
for file_ in files:
file_paths.append(pure_service.download_file(identity, file_))
file_paths = [pure_service.download_file(identity, file_) for file_ in files]
except (PureRESTError, PureRuntimeError) as error:
raise RuntimeError(str(error)) from error

Expand Down

0 comments on commit 7b69654

Please sign in to comment.