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
3 changes: 2 additions & 1 deletion dandi/organize.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from enum import Enum
import os
import os.path as op
import posixpath
from pathlib import Path, PurePosixPath
import re
import traceback
Expand Down Expand Up @@ -275,7 +276,7 @@ def _create_external_file_names(metadata: list[dict]) -> list[dict]:
renamed_path_list = []
uuid_str = ext_file_dict.get("id", str(uuid.uuid4()))
for no, ext_file in enumerate(ext_file_dict["external_files"]):
renamed = op.join(
renamed = posixpath.join(
nwb_folder_name, f"{uuid_str}_external_file_{no}{ext_file.suffix}"
)
renamed_path_list.append(renamed)
Expand Down
6 changes: 3 additions & 3 deletions dandi/pynwb_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import inspect
import os
import os.path as op
from pathlib import Path
from pathlib import Path, PurePosixPath
import re
from typing import IO, Any, TypeVar, cast
import warnings
Expand Down Expand Up @@ -408,8 +408,8 @@ def _get_image_series(nwb: pynwb.NWBFile) -> list[dict]:
if isinstance(ob, pynwb.image.ImageSeries) and ob.external_file is not None:
out_dict = dict(id=ob.object_id, name=ob.name, external_files=[])
for ext_file in ob.external_file:
if Path(ext_file).suffix in VIDEO_FILE_EXTENSIONS:
out_dict["external_files"].append(Path(ext_file))
if (path := PurePosixPath(ext_file)).suffix in VIDEO_FILE_EXTENSIONS:
out_dict["external_files"].append(path)
else:
lgr.warning(
"external file %s should be one of: %s",
Expand Down
4 changes: 4 additions & 0 deletions dandi/tests/test_organize.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@ def test_video_organize(
for ext_file_ob in ext_file_objects:
for no, name in enumerate(ext_file_ob["external_files"]):
video_files_organized.append(name)
# Regression: external_file paths are DANDI/S3 keys,
# must use forward slashes even on Windows.
# See https://github.com/catalystneuro/nwb-video-widgets/issues/33
assert "\\" not in str(name)
# check if external_file arguments are correctly named according to convention:
filename = Path(
f"{vid_folder.name}/{ext_file_ob['id']}_external_file_{no}"
Expand Down
Loading