devops.cpp.license_header

Module to check for license headers in C++ files.

Functions

add_license_header(file, header_to_add, *[, ...])

Add the license header to the file content if it's missing.

check_license_header(file_rule_input, ...)

Check if the file content starts with the required license header.

Classes

CheckLicenseHeader(header_to_check)

Rule to check for the presence of a license header in C++ files.

devops.cpp.license_header.check_license_header(file_rule_input, required_header_file)[source]

Check if the file content starts with the required license header.

Parameters:
  • file_rule_input (FileRuleInput) – The input containing the file content and path to check.

  • required_header_file (str | Path) – The path to the file containing the required license header.

Returns:

ResultType – The result of the license header check.

Raises:

DevOpsFileNotFoundError – If the required header file does not exist.

Return type:

ResultType

devops.cpp.license_header.add_license_header(file, header_to_add, *, dry_run=False)[source]

Add the license header to the file content if it’s missing.

Parameters:
  • file (str | Path) – The path to the file to modify.

  • header_to_add (str | Path) – The path to the file containing the license header to add.

  • dry_run (bool) – If True, do not modify the file, only simulate the addition.

Returns:

bool – True if the license header was added, False if it was already present.

Raises:

DevOpsFileNotFoundError – If the header file does not exist.

Return type:

bool

class devops.cpp.license_header.CheckLicenseHeader(header_to_check)[source]

Bases: Rule

Rule to check for the presence of a license header in C++ files.

Parameters:

header_to_check (str | Path)