ocebuild.pipeline.config#

Methods for retrieving and handling config.plist files and patches.

Module Contents#

Functions#

read_config(→ Tuple[dict, Union[dict, None]])

Reads a configuration file.

apply_preprocessor_tags(→ None)

Applies preprocessor tags from dict b on dict a.

merge_configs(→ Dict)

Merges a set of plist or yaml config files into a single config.

get_configuration_schema(→ Union[dict, Tuple[dict, dict]])

Reads the Sample.plist schema from a OpenCorePkg version.

ocebuild.pipeline.config.read_config(filepath: str, frontmatter: bool = False, flags: List[str] | None = None) Tuple[dict, dict | None][source]#

Reads a configuration file.

Parameters:
  • filepath – The path to the configuration file.

  • frontmatter – Whether to include the file’s frontmatter.

  • flags – The flags to apply to the configuration file.

Raises:

ValueError – If the file extension is not supported.

Returns:

The configuration file.

If frontmatter is True, a tuple containing:
  • The configuration file.

  • The frontmatter of the configuration file.

ocebuild.pipeline.config.apply_preprocessor_tags(a: dict, b: dict, tags: List[Tuple[str, List[str], str | None]]) None[source]#

Applies preprocessor tags from dict b on dict a.

Parameters:
  • a – The dict to apply preprocessor tags to.

  • b – The dict annotated by the preprocessor tags.

  • tags – The preprocessor tags to apply.

Raises:

ValueError – If the tag is not recognized.

Notes

Preprocessor tags are applied in the following order: - @append: Append values from b to a. - @delete: Delete a and b if b is empty. - @fallback: Use b if a is empty. - @override: Override a with b if a contains the same key. - @prepend: Prepend values from b to a.

ocebuild.pipeline.config.merge_configs(base: str | ocebuild.third_party.cpython.pathlib.Path, *patches: str | ocebuild.third_party.cpython.pathlib.Path, flags: List[str] | None = None) Dict[source]#

Merges a set of plist or yaml config files into a single config.

Parameters:
  • base – The base config file.

  • *patches – The patch config files.

  • flags – The flags to apply to the configuration file.

Returns:

The merged config.

Raises:

ValueError – If a patch file is not a plist or yaml file.

Example

>>> merge_configs('base.plist', 'patch1.yml', 'patch2.plist', 'patch2.yaml')
{...}
ocebuild.pipeline.config.get_configuration_schema(repository: str = 'acidanthera/OpenCorePkg', branch: str = 'master', tag: str | None = None, commit: str | None = None, get_sample: bool = False, **kwargs) dict | Tuple[dict, dict][source]#

Reads the Sample.plist schema from a OpenCorePkg version.