llama.lock module

A mechanism for marking a file as locked, i.e. not eligible for automatic regeneration, or as obsolete, i.e. eligible for automatic regeneration. It can still manually be changed in either case.

class llama.lock.LockHandler

Bases: llama.lock.LockHandlerTuple

A class for marking a set of paths as locked, i.e. not eligible for automated obsolescence and regeneration. At time of writing, this is accomplished by creating an empty lockfile that llama.filehandler.FileHandler.is_obsolete will check for. The manifest should filenames (as returned by basename or llama.filehandler.FileHandler.filename). Is also used for precomputing obsolescence values and storing the results in obsolescence_files.

is_locked

Check whether the files in this manifest are locked.

lock()

Mark the files in this manifest as locked. Since locking prevents obsolescence, marking a file as locked will also write cache the obsolescence value as False.

lockfiles

A list of lockfiles associated with this manifest. If any of these exists, all files in the manifest are considered locked. Create these files to mark them as locked.

lockpaths

Full paths to lockfiles for this manifest.

obsolescence

Get the precomputed obsolescence value for this manifest (if it exists); raise an FileNotFoundError if none is available and a ValueError if a valid value could not be read from the obsolescence file.

obsolescence_files

A list of obsolescence file names associated with this manifest. If any of these exists, the obsolescence status of the manifest will be read from it. Create these files to store precomputed or manual obsolescence values.

obsolescence_paths

Full paths to obsolescence files for this manifest.

record_obsolescence(obsolete)

Store the file’s obsolescence values. Will ignore any locks, which separately veto obsolescence.

remove_all_obsolescence()

Delete all obsolescence cache files for this event.

remove_obsolescence()

Delete obsolescence files recording obsolescence state.

unlock()

Mark the files in this manifest as unlocked. Will remove any cached obsolescence values (since obsolescence must now be recalculated).

class llama.lock.LockMixin

Bases: object

A mixin that lets FileHandler-like objects (producing a manifest and eventdir) mark files as locked, i.e. inelligible for automatic obsolescence checks and subsequent regeneration. This functionality is added via a lock property on the FileHandler-like object with sub-methods implementing its functionality.

lock

Return a LockHandler instance corresponding to this FileHandler and all other file paths in its manifest.

llama.lock.cache_obsolescence(func)

Decorator for a LockMixin instance’s obsolescence check method that marks all files in the manifest with the returned obsolescence value of the decorated method. Immediately returns a cached obsolescence value if stored.

llama.lock.trash_obsolescence(func)

Decorator for a LockMixin instance’s generation method that removes all obsolescence files for the instance’s manifest. Used for cache invalidation.