craft_parts.utils.partition_utils module¶
Unit tests for partition utilities.
- craft_parts.utils.partition_utils.get_partition_dir_map(base_dir, partitions, suffix='')[source]¶
Return a mapping of partition directories.
The default partition maps to directories in the base_dir. All other partitions map to directories in partitions/<partition-name>.
If no partitions are provided, return a mapping of None to base_dir/suffix.
- Parameters:
base_dir (
Path) – Base directory.partitions (
Sequence[str] |None) – An iterable of partition names.suffix (
str) – String containing the subdirectory to map to inside each partition.
- Return type:
dict[str|None,Path]- Returns:
A mapping of partition names to paths.
- craft_parts.utils.partition_utils.is_default_partition(partitions, partition)[source]¶
Check if given partition is the default one in the given partition list.
- Parameters:
partitions (
list[str] |None)partition (
str|None)
- Return type:
bool
- craft_parts.utils.partition_utils.validate_partition_names(partitions)[source]¶
Validate the partition feature set.
- If the partition feature is enabled, then:
each partition name must contain only lowercase alphanumeric characters hyphens and slashes, but not begin or end with a hyphen or a slash
partitions are unique
only the first partition can be named “default”
Namespaced partitions can also be validated in addition to regular (or ‘non-namespaced’) partitions. The format is <namespace>/<partition>.
Namespaced partition names follow the same conventions described above. Namespace names must consist of only lowercase alphanumeric characters.
- Parameters:
partitions (
Sequence[str] |None) – Partition data to verify.- Raises:
ValueError – If the partitions are not valid or the feature is not enabled.
- Return type:
None