Skip to content

Module gamster.create_bag

The create_bagmodule provides function to convert an object directory into a GAMS bag.

The most important function is make_bag()

gamster.create_bag

Create a Bagit directory from object folders.

logger module-attribute

logger = logging.getLogger(__name__)

write_sip_json

write_sip_json(bag_dir, json_data)

Write sip.json to the bagit object folder.

write_bagit_txt

write_bagit_txt(bag_dir)

Create the bagit.txt file in the object bagit folder.

write_manifest_md5

write_manifest_md5(bag_dir, manifest_data)

Write the manifest-md5.txt file to the bagit object folder.

write_manifest_sha512

write_manifest_sha512(bag_dir, manifest_data)

Write the manifest-sha512.txt file to the bagit object folder.

write_bag_info_txt

write_bag_info_txt(bag_dir, sip_json)

Write the bag-info.txt file to the bagit object folder.

cleanup_bag_dir

cleanup_bag_dir(bag_path, overwrite_bag=False)

Check if the bag (either a folder or a zip archive) already exists and remove it if overwrite_bag is True.

Raises BagExistsError if the bag directory or bag zip archive already exists and overwrite_bag is False.

If overwrite_bag is True, a warning is issued and the existing bag directory and/or zip archive is removed before creating a new bag directory.

create_temporary_bag_dir

create_temporary_bag_dir(pid, object_dir, sip_json)

Create a temporary Bagit directory for the object folder.

The temporary directory will be created in the system's temp directory. Purpose is to prepare the bagit structure and files and to validate the bag before moving it to the final location.

Returns the path to the temporary directory.

make_bag

make_bag(object_dir, output_root, overwrite_bag=False, as_zip=False)

Create a Bagit directory for files in object_dir.

The resulting directory will be created under the output_root directory. Returns the path of the created bag directory. Raises BagExistsError if the bag directory already exists and overwrite_bag is False. Raises gamslib.sip.BagValidationError if the bag validation fails.