Skip to content

Commit

Permalink
Merge pull request #592 from dylanmcreynolds/tiff_names
Browse files Browse the repository at this point in the history
add dummy file name for some tiffseq
  • Loading branch information
Wiebke authored Oct 26, 2023
2 parents 81804e1 + 5b221db commit 1db4a8b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
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

0 comments on commit 1db4a8b

Please sign in to comment.