Skip to content

Commit

Permalink
Apply automatic formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci-lite[bot] authored Nov 1, 2024
1 parent 93eed85 commit 5e04499
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/scicat_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class FileHandlingOptions:
ingestor_files_directory: str = "../ingestor"
message_to_file: bool = True
message_file_extension: str = "message.json"
file_path_type: str = "relative" # allowed values: absolute and relative
file_path_type: str = "relative" # allowed values: absolute and relative


@dataclass(kw_only=True)
Expand Down
27 changes: 10 additions & 17 deletions src/scicat_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ def extract_paths_from_h5_file(
for key in temp_keys:
output_paths += [
key + "/" + subkey
for subkey
in extract_paths_from_h5_file(
for subkey in extract_paths_from_h5_file(
_h5_object[key], copy.deepcopy(_path)
)
]
Expand Down Expand Up @@ -607,9 +606,9 @@ def scicat_dataset_to_dict(dataset: ScicatDataset) -> dict:


def _define_dataset_source_folder(
datafilelist: list[DataFileListItem],
data_file_path: pathlib.Path,
source_folder_config: str = "common_path"
datafilelist: list[DataFileListItem],
data_file_path: pathlib.Path,
source_folder_config: str = "common_path",
) -> pathlib.Path | None:
"""
Return the dataset source folder, which is the common path
Expand All @@ -624,10 +623,11 @@ def _define_dataset_source_folder(
else:
return None


def _path_to_relative(
datafilelist_item: DataFileListItem,
dataset_source_folder: pathlib.Path,
file_path_type: str = "relative"
file_path_type: str = "relative",
) -> DataFileListItem:
"""
Copy the datafiles item and transform the path to the relative path
Expand All @@ -648,20 +648,15 @@ def _path_to_relative(
def _prepare_origdatablock_datafilelist(
datafiles_list: list[DataFileListItem],
dataset_source_folder: pathlib.Path,
file_path_type: str = "relative"
file_path_type: str = "relative",
) -> list[DataFileListItem]:
"""
Prepare the datafiles list for the origdatablock entry in scicat
That means that the file paths needs to be relative to the dataset source folder
"""
return [
_path_to_relative(
item,
dataset_source_folder,
file_path_type
)
for item
in datafiles_list
_path_to_relative(item, dataset_source_folder, file_path_type)
for item in datafiles_list
]


Expand All @@ -671,9 +666,7 @@ def create_origdatablock_instance(
config: FileHandlingOptions,
) -> OrigDataBlockInstance:
origdatablock_datafiles_list = _prepare_origdatablock_datafilelist(
data_file_list,
scicat_dataset["sourceFolder"],
config.file_path_type
data_file_list, scicat_dataset["sourceFolder"], config.file_path_type
)
return OrigDataBlockInstance(
datasetId=scicat_dataset["pid"],
Expand Down

0 comments on commit 5e04499

Please sign in to comment.