craft_parts.overlays.layers module

Layer management and helpers.

class craft_parts.overlays.layers.LayerHash(layer_hash)[source]

Bases: object

The layer validation hash for a part.

Parameters:

layer_hash (bytes) –

classmethod for_part(part, *, previous_layer_hash)[source]

Obtain the validation hash for a part.

Parameters:
  • part (Part) – The part being processed.

  • previous_layer_hash (Optional[LayerHash]) – The validation hash of the previous layer in the overlay stack.

Return type:

LayerHash

Returns:

The validation hash computed for the layer corresponding to the given part.

hex()[source]

Return the current hash value as a hexadecimal string.

Return type:

str

classmethod load(part)[source]

Read the part layer validation hash from persistent state.

Parameters:

part (Part) – The part whose layer hash will be loaded.

Return type:

Optional[LayerHash]

Returns:

A layer hash object containing the loaded validaton hash, or None if the file doesn’t exist.

save(part)[source]

Save the part layer validation hash to persistent storage.

Parameters:

part (Part) – The part whose layer hash will be saved.

Return type:

None

class craft_parts.overlays.layers.LayerStateManager(part_list, base_layer_hash)[source]

Bases: object

An in-memory layer state management helper for action planning.

Parameters:
  • part_list (List[Part]) – The list of parts in the project.

  • base_layer_hash (Optional[LayerHash]) – The verification hash of the overlay base layer.

compute_layer_hash(part)[source]

Calculate the layer validation hash for the given part.

Parameters:

part (Part) – The part being processed.

Return type:

LayerHash

Returns:

The validation hash of the layer corresponding to the given part.

get_layer_hash(part)[source]

Obtain the layer hash for the given part.

Parameters:

part (Part) –

Return type:

Optional[LayerHash]

get_overlay_hash()[source]

Obtain the overlay validation hash.

Return type:

bytes

set_layer_hash(part, layer_hash)[source]

Store the value of the layer hash for the given part.

Parameters:
Return type:

None