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 (
Iterable
[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.validate_partition_names(partitions)[source]¶
Validate the partition feature set.
- If the partition feature is enabled, then:
the first partition must be “default”
each partition name must contain only lowercase alphanumeric characters and hyphens, but not begin or end with a hyphen
partitions are unique
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