API Docs

Pythonic API for interacting with an OCFL storage root.

class ocflcore.FileSystemStorage(root_path)[source]

File system storage.

Construct the file system.

Parameters

root_path – Path to the storage root.

move(other_storage, path)[source]

Move between storage systems.

write(file_path, stream)[source]

Write stream to the given file path in the storage root.

Automatically creates missing directories, and uses a 1MB chunk size.

class ocflcore.OCFLObject(object_id, content_directory='content', digest_algorithm='sha512', spec='1.1')[source]

Logical representation of an OCFL Object.

OCFL Object constructor.

property content_directory

Get the content directory.

content_files(version=None)[source]

Iterate over deduplicated list of content files.

property digest_algorithm

Get the digest algorithm.

property head

Get the most recent version.

property id

Get the object identifier.

property spec

Get OCFL specification for this object.

property version_numbers

Return a range of version numbers.

property versions

Get the object identifier.

class ocflcore.OCFLRepository(root, storage, workspace_storage=None)[source]

Repository for OCFL objects.

The repository takes care of reading and writing of OCFL objects in the OCFL storage root, as well as handling updates.

The class is named repository after the repository pattern in “Fowler (2002). Patterns of Enterprise Application Architecture”.

Constrcutor.

add(obj)[source]

Add an OCFL object to the storage root.

add_version(obj_id, version)[source]

Add new version to an OCFL object.

get(obj_id)[source]

Get an OCFL object from the storage root.

initialize()[source]

Initialize OCFL repository.

list()[source]

List objects in an OCFL object root.

class ocflcore.OCFLVersion(creation_time)[source]

Logical representation of a version.

Constructor.

property created

Creation date.

property files

Get the object identifier.

property index

Get the version index.

property message

Get the message.

property state

Version state.

property user

Get the message.

class ocflcore.StorageLayout[source]

Base class for storage root hierarchies layouts.

property data

Get a dictionary for the ocfl_layout.json file.

property json_bytes

Get the JSON serialization of this storage root.

path_for(obj)[source]

Compute path for a given object.

class ocflcore.StorageRoot(layout, version='1.1')[source]

OCFL storage root representation.

Constructor.

property human_text

Human readable text of the OCFL spec.

property human_text_filename

Filename of the OCFL spec.

property namaste

Name as text filename for this storage root.

class ocflcore.StreamDigest(stream, algo='sha512')[source]

Utility class for read a stream and computing a digest.

The stream must support random seek.

Constructor.

property digest

Compute the digest and set seek stream back to beginning.

class ocflcore.TopLevelLayout[source]

Simple top-level layout class.

path_for(obj)[source]

Top-level just uses the object ID.