Skip to main content

simple python interface for creating and interacting with files in the BagIt-format

Project description

BagItUtils

This repository contains a simple python interface for creating and interacting with files in the BagIt-format (v1.0). It does not provide a complete implementation of the specification. Please refer to the examples-section for a description of supported features.

Basic usage examples

Initialize an existing Bag with

from pathlib import Path
from bagit_utils import Bag

bag = Bag(Path("path/to/bag"))

Access bag-metadata via properties

print(bag.baginfo)
print(bag.manifests)
print(bag.tag_manifests)

Reload data after initialization

bag = Bag(Path("path/to/bag"))

# .. some operation that changes bag-info.txt

bag.load_baginfo()

Update manifests (on disk) after changes to the bag-payload/tag-files occurred

bag = Bag(Path("path/to/bag"))

# .. some operation that, e.g., adds/removes/changes files in data/ or meta/

bag.generate_manifests()
bag.generate_tag_manifests()

Update bag-info after initialization

bag = Bag(Path("path/to/bag"))

bag.generate_baginfo(
    bag.baginfo | {"AdditionalField": ["value0", "value1"]}
)

Create bag from source

bag = Bag.build_from(
    Path("path/to/source"),  # should contain payload in data/-directory
    Path("path/to/bag"),  # should be empty
    baginfo={
        "Source-Organization": ["My Organization"].
        ...,
        "Payload-Oxum": [Bag.get_payload_oxum(Path("path/to/source"))],
        "Bagging-Date": [Bag.get_bagging_date()],
    },
    algorithms=["md5", "sha1"],
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bagit_utils-0.1.0.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bagit_utils-0.1.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file bagit_utils-0.1.0.tar.gz.

File metadata

  • Download URL: bagit_utils-0.1.0.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for bagit_utils-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c2d411dfe81cdeb27b6e71827dce369763af5cb2cb6a0b87c71482749748c43f
MD5 a486d021a6d4b6c067e9ecb90311669a
BLAKE2b-256 c54471ef5216717c84ab8158956b41cf533626070df6675675a0f3a139128011

See more details on using hashes here.

File details

Details for the file bagit_utils-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bagit_utils-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for bagit_utils-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff201791e46d0610895467505c51e9749424c01bdd629c00ac73a9fa1c637501
MD5 7b444282f08df5a2256df5011563ec8b
BLAKE2b-256 3340392364ae00ded68965c28c73327c0eb5bd9bbfd2293290e312c66ce18141

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page