BagIt Profile Validator

1.3.1 · active · verified Fri Apr 17

The `bagit-profile` library provides tools to validate BagIt Profiles, ensuring that digital preservation packages conform to a specified set of rules. It is designed to work in conjunction with the `bagit` library to validate actual BagIt bags against these profiles. The current version is 1.3.1, with an infrequent release cadence (last major release in 2020).

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to load a BagIt Profile from a remote URI. It prints some basic information from the loaded profile. To perform actual validation, you would additionally need to create or load a `bagit.Bag` object and pass it to the `profile.validate()` method.

import os
from bagit_profile import BagitProfile

# Define a public BagIt Profile URI for demonstration
profile_uri = "https://raw.githubusercontent.com/bagit-profiles/bagit-profiles/master/bagitProfileFAB.json"

print(f"Attempting to load BagIt Profile from URI: {profile_uri}")

try:
    # Load the BagIt Profile from the URI
    profile = BagitProfile.from_uri(profile_uri)
    
    print(f"\nSuccessfully loaded profile with identifier: {profile.bag_profile_identifier}")
    print(f"Profile version: {profile.profile_version}")
    print(f"BagIt-Profile-Description: {profile.bag_info.get('BagIt-Profile-Description', 'N/A')}")
    
    # To perform actual validation, you would need a 'bagit.Bag' object:
    # from bagit import Bag
    # bag = Bag('/path/to/your/bag') # Replace with an actual Bag path
    # is_valid = profile.validate(bag)
    # print(f"\nBag validation result: {is_valid}")
    # if not is_valid:
    #     print("Validation errors:")
    #     for error in profile.errors:
    #         print(f"- {error}")

except Exception as e:
    print(f"\nAn error occurred during profile loading: {e}")

view raw JSON →