Skip to content

Commit

Permalink
Merge pull request #249 from RockefellerArchiveCenter/issue-248
Browse files Browse the repository at this point in the history
Support bags with TIFFs in `master` directory
  • Loading branch information
helrond authored Oct 21, 2024
2 parents 22235d8 + 0c1ae96 commit 68b1cc5
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ArchivesSpace-URI: /repositories/2/archival_objects/1234
Bag-Software-Agent: bagit.py <http://github.com/libraryofcongress/bagit-python>
BagIt-Profile-Identifier: http://localhost:8000/api/bagit_profiles/1/
Bagging-Date: 2017-12-11T20:10:28.813474
Date-End: 1999-06-22
Date-Start: 1994-05-14
External-Identifier: records-2017-12-11T20:10:28.813474
Internal-Sender-Description: Grant awarded to the Village Green Preservation Society for the purpose of "preserving the old ways from being abused, protecting the new ways for me and for you"
Language: eng
Origin: digitization
Payload-Oxum: 1131930.1
Record-Creators: Custard Pie Appreciation Consortium
Record-Creators: Desperate Dan Appreciation Society
Record-Type: grant records
Restrictions: Records open only to Mrs. Mopp and good old Mother Riley
Source-Organization: Test Organization
Title: Grant to the Village Green Preservation Society
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BagIt-Version: 0.97
Tag-File-Character-Encoding: UTF-8
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
df87217e2c181ae6674898dff27e5a56 data/file_example_TIFF_1MB.tiff
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
9e5ad981e0d29adc278f6a294b8c2aca bagit.txt
387c1c0bfc4c7a4e75e17358029e4bdc bag-info.txt
53c3a2ca7138cdd8bf4b622e80dec9cd manifest-md5.txt
7 changes: 5 additions & 2 deletions create_derivatives/routines.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,11 @@ def get_tiff_file_paths(self, bag_path):
tiff_files (list of pathlib.Paths): absolute filepaths for TIFF files.
"""
service_dir = Path(bag_path, "data", "service")
if service_dir.is_dir() and any(service_dir.iterdir()):
tiff_files_dir = Path(bag_path, "data", "service")
master_dir = Path(bag_path, "data", "master")
for tiff_dir in service_dir, master_dir:
if tiff_dir.is_dir() and any(tiff_dir.iterdir()):
tiff_files_dir = tiff_dir
break
else:
tiff_files_dir = Path(bag_path, "data")
return matching_files(tiff_files_dir, prepend=True)
Expand Down
12 changes: 7 additions & 5 deletions create_derivatives/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,18 @@ def test_tiff_file_paths(self):
Files in a service directory should be returned if present, otherwise
TIFFs in the data directory should be returned.
"""
for fixture_path, expected in [
("unpacked_bag_with_tiff", False),
("unpacked_bag_with_tiff_empty_service", False),
("unpacked_bag_with_tiff_service", True)]:
for fixture_path, expected_service, expected_master in [
("unpacked_bag_with_tiff", False, False),
("unpacked_bag_with_tiff_empty_service", False, False),
("unpacked_bag_with_tiff_master", False, True),
("unpacked_bag_with_tiff_service", True, False)]:
set_up_bag(settings.TMP_DIR, fixture_path, self.bag_id)
bag = Bag.objects.last()
tiffs = JP2Maker().get_tiff_file_paths(bag.bag_path)
for path in tiffs:
self.assertTrue("data" in str(path))
self.assertEqual("service" in str(path), expected)
self.assertEqual("service" in str(path), expected_service)
self.assertEqual("master" in str(path), expected_master)
shutil.rmtree(bag.bag_path)

def tearDown(self):
Expand Down

0 comments on commit 68b1cc5

Please sign in to comment.