craft_parts.executor.organize module

Handle part files organization.

Installed part files can be reorganized according to a mapping specified under the organize entry in a part definition. In the key/value pair, the key represents the path of a file inside the part and the value represents how the file is going to be staged.

craft_parts.executor.organize.organize_files(*, part_name, file_map, install_dir_map, overwrite)[source]

Rearrange files for part staging.

If partitions are enabled, source filepaths must be in the default partition.

Parameters:
  • part_name (str) – The name of the part to organize files for.

  • file_map (Dict[str, str]) – A mapping of source filepaths to destination filepaths.

  • install_dir_map (Mapping[Optional[str], Path]) – A mapping of partition names to their install directories.

  • overwrite (bool) – Whether existing files should be overwritten. This is only used in build updates, when a part may organize over files it previously organized.

Raises:
  • FileOrganizeError – If the destination file already exists or multiple files are organized to the same destination.

  • FileOrganizeError – If partitions are enabled and the source file is not from the default partition.

Return type:

None