Skip to content

Commit

Permalink
Merge pull request #253 from RockefellerArchiveCenter/development
Browse files Browse the repository at this point in the history
Factor out method to get TIFF files
  • Loading branch information
helrond authored Oct 21, 2024
2 parents e210d6d + be437d3 commit ee359b9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
18 changes: 18 additions & 0 deletions create_derivatives/migrations/0004_alter_bag_origin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.0.10 on 2024-10-21 20:44

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('create_derivatives', '0003_bag_pdf_path'),
]

operations = [
migrations.AlterField(
model_name='bag',
name='origin',
field=models.CharField(choices=[('aurora', 'Aurora'), ('legacy_digital', 'Legacy Digital Processing'), ('digitization', 'Digitization'), ('av_digitization', 'Audiovisual Digitization')], default='aurora', max_length=20),
),
]
25 changes: 5 additions & 20 deletions create_derivatives/routines.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,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 Expand Up @@ -149,24 +152,6 @@ def process_bag(self, bag):
tiff_files = self.get_tiff_file_paths(bag.bag_path)
self.convert_to_strips(tiff_files)

def get_tiff_file_paths(self, bag_path):
"""Determines the location of TIFF files in the bag.
Args:
bag_path (str): root bag path.
Returns:
tiff_files (list of pathlib.Paths): absolute filepaths for TIFF files.
"""
service_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)

def convert_to_strips(self, tiff_files):
"""Converts tiled TIFFs to stripped TIFFs.
Expand Down

0 comments on commit ee359b9

Please sign in to comment.