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

Support different bag structures #250

Merged
merged 3 commits into from
Oct 21, 2024
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
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
Loading