e3_build_tools.utils

Module with utils functions to e3_build_tools.

Attributes

Classes

WrapperType

Enum of wrapper types.

Functions

get_wrapper_type(→ WrapperType)

Check wrapper type.

read_makefile_definitions(→ Dict[str, str])

Return the definitions of makefile variables.

modify_makefile_definitions(→ str)

Overwrite the definitions of makefile variables.

modify_config_file(→ None)

Modify the data in a config file.

check_module_version(→ bool)

Return if module version is in the expected format.

check_require_version(→ bool)

Return if require version is in the expected format.

check_base_version(→ bool)

Return if base version is in the expected format.

ensure_build_number(→ str)

Return the same string but with +0 appended if string is a valid version.

increment_build_number(→ str)

Return a version with incremented build number.

extract_base_version(→ str)

Return the version as taken from a path to EPICS base.

deep_merge(→ Type[Dict])

Return a nested merge of two dictionaries, with first taking precedence.

run_make(→ subprocess.CompletedProcess)

Run GNU make in the target directory with the given arguments.

Module Contents

e3_build_tools.utils.logger[source]
class e3_build_tools.utils.WrapperType(*args, **kwds)[source]

Bases: enum.Enum

Enum of wrapper types.

BASE[source]
REQUIRE[source]
MODULE[source]
e3_build_tools.utils.get_wrapper_type(wrapper: git.Repo | pathlib.Path) WrapperType[source]

Check wrapper type.

Raises:

TypeError: If current directory is not a module.

e3_build_tools.utils.read_makefile_definitions(content: str) Dict[str, str][source]

Return the definitions of makefile variables.

e3_build_tools.utils.modify_makefile_definitions(content: str, substitutions: Dict[str, str]) str[source]

Overwrite the definitions of makefile variables.

Declarations that are commented out are ignored.

e3_build_tools.utils.modify_config_file(filename: pathlib.Path, key: str, val: str) None[source]

Modify the data in a config file.

e3_build_tools.utils.check_module_version(version: str) bool[source]

Return if module version is in the expected format.

e3_build_tools.utils.check_require_version(version: str) bool[source]

Return if require version is in the expected format.

e3_build_tools.utils.check_base_version(version: str) bool[source]

Return if base version is in the expected format.

Unfortunately epics base does not follow semantic version and sometimes can have one digit more, like on version 7.0.6.1.

e3_build_tools.utils.ensure_build_number(version: str) str[source]

Return the same string but with +0 appended if string is a valid version.

We have to deal with the implicit addition of +0 by require to modules that have no build number defined, but we only do this for versions of the form “x.y.z”.

e3_build_tools.utils.increment_build_number(version: str) str[source]

Return a version with incremented build number.

e3_build_tools.utils.extract_base_version(base_path: str) str[source]

Return the version as taken from a path to EPICS base.

Raises:

ValueError: If base_path is not a valid EPICS base path.

e3_build_tools.utils.deep_merge(first: Type[Dict], second: Type[Dict]) Type[Dict][source]

Return a nested merge of two dictionaries, with first taking precedence.

Based on https://stackoverflow.com/a/56177639

Each key that is found only in first or only in second will be included in the output collection with its value intact. For any key in common between first and second, the corresponding values will be merged, and first will take precedence over second.

e3_build_tools.utils.run_make(path: pathlib.Path, *makeargs) subprocess.CompletedProcess[source]

Run GNU make in the target directory with the given arguments.