index

class PimarcIndex[source]

Bases: object

Simple index to accompany a Pimarc, stored along with the .prc file as a .prci file. Provides a list of the filenames in the archive, along with the starting byte of the file’s metadata and data.

filenames is an OrderedDict mapping filename -> (metadata start byte, data start byte).

get_metadata_start_byte(filename)[source]
get_data_start_byte(filename)[source]
keys()[source]
append(filename, metadata_start, data_start)[source]
static load(filename)[source]
save(path)[source]
class PimarcIndexAppender(store_path, mode='w')[source]

Bases: object

Class for writing out a Pimarc index as each file is added to the archive. This is used by the Pimarc writer, instead of creating a PimarcIndex and calling save(), so that the index is always kept up to date with what’s in the archive.

Mode may be “w” to write a new index or “a” to append to an existing one.

append(filename, metadata_start, data_start)[source]
close()[source]
flush()[source]
reindex(pimarc_path)[source]

Rebuild the index of a Pimarc archive from its data file (.prc).

Stores the new index in the correct location (.prci), overwriting any existing index.

Parameters:pimarc_path – path to the .prc file
Returns:the PimarcIndex
check_index(pimarc_path)[source]

Check through a Pimarc file together with its index to identify any places where the index does not match the archive contents.

Useful for debugging writing/reading code.

exception IndexCheckFailed[source]

Bases: Exception

exception FilenameNotInArchive(filename)[source]

Bases: Exception

exception DuplicateFilename(filename)[source]

Bases: Exception

exception IndexWriteError[source]

Bases: Exception