Skip to content

Commit

Permalink
put metadata.csv in its own folder
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-butcher committed Jun 11, 2024
1 parent c78af4a commit 2e66119
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/transferrer/make_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def generate_metadata_csv(csvfile, accession_id):


def create_born_digital_folder(source_files, target_directory, accession_id):
os.makedirs(target_directory, exist_ok=True)
with open(os.path.join(target_directory, "metadata.csv"), "w") as csvfile:
os.makedirs(os.path.join(target_directory, "metadata"), exist_ok=True)
with open(os.path.join(target_directory, "metadata", "metadata.csv"), "w") as csvfile:
generate_metadata_csv(csvfile, accession_id)
move_files_to_objects_folder(source_files, target_directory)
return target_directory
Expand Down
6 changes: 3 additions & 3 deletions test/test_make_zips.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_single_zip(fs):
with zipfile.ZipFile("./1234_G00DCAFE.zip") as zip_file:
zip_file.extractall("/unzipped")
# with a metadata csv in the root of the zip
assert_csv_has_accession_id("/unzipped/metadata.csv", "1234_G00DCAFE")
assert_csv_has_accession_id("/unzipped/metadata/metadata.csv", "1234_G00DCAFE")
# and the photos in an ./objects folder
assert os.path.exists("/unzipped/objects/G00DCAFE_001.tif")
assert os.path.exists("/unzipped/objects/G00DCAFE_002.tif")
Expand All @@ -68,7 +68,7 @@ def test_multiple_zips(fs):
# it creates zips named using the accession and shoot numbers, with a three-digit numeric suffix
with zipfile.ZipFile("./1234_G00DCAFE_001.zip") as zip_file:
zip_file.extractall("/unzipped_001")
assert_csv_has_accession_id("/unzipped_001/metadata.csv", "1234_G00DCAFE_001")
assert_csv_has_accession_id("/unzipped_001/metadata/metadata.csv", "1234_G00DCAFE_001")
# The objects chosen for each zip are predictable and consistent.
# They are sorted alphanumerically before being sliced into groups to place into each zip
objects = os.listdir("/unzipped_001/objects")
Expand All @@ -77,7 +77,7 @@ def test_multiple_zips(fs):

with zipfile.ZipFile("./1234_G00DCAFE_002.zip") as zip_file:
zip_file.extractall("/unzipped_002")
assert_csv_has_accession_id("/unzipped_002/metadata.csv", "1234_G00DCAFE_002")
assert_csv_has_accession_id("/unzipped_002/metadata/metadata.csv", "1234_G00DCAFE_002")
objects = os.listdir("/unzipped_002/objects")
assert len(objects) == 10
assert set(filename[:3] for filename in objects) == {"BBB"}
Expand Down

0 comments on commit 2e66119

Please sign in to comment.