From 16fe35a40f2f67a62f5b39179a36b005987eafcf Mon Sep 17 00:00:00 2001 From: Hillel Arnold Date: Mon, 21 Oct 2024 16:45:06 -0400 Subject: [PATCH 1/2] factor out method --- create_derivatives/routines.py | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/create_derivatives/routines.py b/create_derivatives/routines.py index e5e2554..ebfc842 100644 --- a/create_derivatives/routines.py +++ b/create_derivatives/routines.py @@ -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) @@ -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. From 04f7017d6ad6eb33ff21f65b198b267a4ac63695 Mon Sep 17 00:00:00 2001 From: Hillel Arnold Date: Mon, 21 Oct 2024 16:45:22 -0400 Subject: [PATCH 2/2] create migration for origin --- .../migrations/0004_alter_bag_origin.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 create_derivatives/migrations/0004_alter_bag_origin.py diff --git a/create_derivatives/migrations/0004_alter_bag_origin.py b/create_derivatives/migrations/0004_alter_bag_origin.py new file mode 100644 index 0000000..275b281 --- /dev/null +++ b/create_derivatives/migrations/0004_alter_bag_origin.py @@ -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), + ), + ]