paths
๐ค AI-Generated Content
This documentation was generated with AI assistance and is still being audited. Some, or potentially a lot, of this information may be inaccurate. Learn more.
flavor.psp.metadata.paths
¶
Path validation and normalization for PSPF metadata.
Ensures all paths in metadata use the {workenv} placeholder for portability. This makes it clear to developers that paths are relative to the work environment.
Functions¶
apply_umask
¶
Apply a umask value to the process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
umask_value
|
int
|
Umask value to apply |
required |
create_workenv_directories
¶
create_workenv_directories(
directories: list[dict[str, str]],
workenv: Path,
umask: str | None = None,
) -> None
Create workenv directories with specified permissions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directories
|
list[dict[str, str]]
|
List of directory configurations |
required |
workenv
|
Path
|
Path to workenv root |
required |
umask
|
str | None
|
Optional umask to apply |
None
|
Source code in flavor/psp/metadata/paths.py
expand_workenv_path
¶
Expand a {workenv} path to an actual filesystem path.
This is used at runtime to convert metadata paths to real paths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path containing {workenv} placeholder |
required |
workenv_dir
|
str
|
Actual workenv directory path |
required |
Returns:
| Type | Description |
|---|---|
str
|
Expanded path |
Examples:
Source code in flavor/psp/metadata/paths.py
make_relative_to_workenv
¶
Convert an absolute path to a {workenv}-relative path.
This is useful when capturing paths during build time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
absolute_path
|
str
|
The absolute path to convert |
required |
workenv_dir
|
str
|
The workenv directory path |
required |
Returns:
| Type | Description |
|---|---|
str
|
Path with {workenv} placeholder |
Examples:
Source code in flavor/psp/metadata/paths.py
parse_mode
¶
Parse a mode string into an integer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode_str
|
str
|
Mode as string (e.g., "0755", "755", "0o755") |
required |
Returns:
| Type | Description |
|---|---|
int
|
Mode as integer |
Raises:
| Type | Description |
|---|---|
ValueError
|
If mode is invalid |
Source code in flavor/psp/metadata/paths.py
substitute_placeholders
¶
Substitute placeholders in a path string.
Supported placeholders: - {workenv}: Work environment directory - {os}: Operating system (darwin, linux, windows) - {arch}: Architecture (amd64, arm64, x86, i386) - {platform}: Combined OS_arch string
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path string with placeholders |
required |
workenv_path
|
Path
|
Path to workenv directory |
required |
Returns:
| Type | Description |
|---|---|
str
|
Path with placeholders substituted |
Source code in flavor/psp/metadata/paths.py
validate_metadata_dict
¶
Recursively validate all paths in a metadata dictionary.
This function walks through the metadata structure and ensures all path-like values use the {workenv} placeholder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metadata
|
dict[str, Any]
|
The metadata dictionary to validate |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Metadata with all paths validated |
Source code in flavor/psp/metadata/paths.py
validate_metadata_list
¶
Validate items in a list, handling both dict and string items.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
items
|
list[Any]
|
The list to validate |
required |
is_path_list
|
bool
|
If True, treat string items as paths |
False
|
Returns:
| Type | Description |
|---|---|
list[Any]
|
List with validated items |
Source code in flavor/psp/metadata/paths.py
validate_metadata_path
¶
Ensure a path in metadata starts with {workenv}.
This function normalizes paths to always use the {workenv} placeholder, making it clear that paths are relative to the work environment directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The path to validate |
required |
Returns:
| Type | Description |
|---|---|
str
|
Path starting with {workenv} |
Examples:
>>> validate_metadata_path("/usr/bin/python")
"{workenv}/bin/python"
>>> validate_metadata_path("bin/python")
"{workenv}/bin/python"
>>> validate_metadata_path("{workenv}/bin/python")
"{workenv}/bin/python"
Source code in flavor/psp/metadata/paths.py
validate_workenv_paths
¶
Validate that all workenv directory paths start with {workenv}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directories
|
list[dict[str, str]]
|
List of directory configurations |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if valid |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any path doesn't start with {workenv} |