Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dummy file name for some tiffseq #592

Merged
merged 5 commits into from
Oct 26, 2023
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 tiled/_tests/test_tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ..adapters.mapping import MapAdapter
from ..adapters.tiff import TiffAdapter, TiffSequenceAdapter
from ..catalog import in_memory
from ..catalog.register import register
from ..catalog.register import TIFF_SEQUENCE_EMPTY_NAME_ROOT, register
from ..client import Context, from_context
from ..server.app import build_app

Expand Down Expand Up @@ -129,6 +129,7 @@ async def test_tiff_sequence_with_directory_walker(tmpdir):
# Single image is its own node.
assert client["single_image"].shape == (3, 5)
# Each sequence is grouped into a node.
assert client[TIFF_SEQUENCE_EMPTY_NAME_ROOT].shape == (10, 3, 5)
assert client["image"].shape == (10, 3, 5)
assert client["other_image"].shape == (10, 3, 5)
assert client["other_image2_"].shape == (10, 3, 5)
Expand Down
3 changes: 3 additions & 0 deletions tiled/catalog/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ async def register_single_item(
# Matches filename with (optional) prefix characters followed by digits \d
# and then the file extension .tif or .tiff.
TIFF_SEQUENCE_STEM_PATTERN = re.compile(r"^(.*?)(\d+)\.(?:tif|tiff)$")
TIFF_SEQUENCE_EMPTY_NAME_ROOT = "_unnamed"


async def tiff_sequence(
Expand Down Expand Up @@ -349,6 +350,8 @@ async def tiff_sequence(
match = TIFF_SEQUENCE_STEM_PATTERN.match(file.name)
if match:
sequence_name, _sequence_number = match.groups()
if sequence_name == "":
sequence_name = TIFF_SEQUENCE_EMPTY_NAME_ROOT
sequences[sequence_name].append(file)
continue
unhandled_files.append(file)
Expand Down