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 (
Optional
[Iterable
[str
]]) – An iterable of partition names.suffix (
str
) – String containing the subdirectory to map to inside each partition.
- Return type:
Dict
[Optional
[str
],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 must contain only lowercase alphabetical characters
partitions are unique
Namespaced partitions can also be validated in addition to regular (or ‘non-namespaced’) partitions. The format is <namespace>/<partition>.
- Namespaced partitions have the following naming convention:
the namespace must contain only lowercase alphabetical characters
the partition must contain only lowercase alphabetical characters and hyphens
the partition cannot begin or end with a hyphen
- Parameters:
partitions (
Optional
[Sequence
[str
]]) – Partition data to verify.- Raises:
ValueError – If the partitions are not valid or the feature is not enabled.
- Return type:
None