Module continuous_delivery_scripts.utils.language_specifics_base
Base class for all Language plugins.
Functions
def get_language_from_file_name(filename: str) ‑> str-
Expand source code
def get_language_from_file_name(filename: str) -> str: """Gets the language from the plugin filename.""" return Path(filename).resolve().with_suffix("").nameGets the language from the plugin filename.
Classes
class BaseLanguage-
Expand source code
class BaseLanguage(ABC): """Base class from which language plugins should inherit from. To write a new language plugin, implement the following methods at a minimum """ def __str__(self) -> str: """String representation.""" return self.__class__.__name__ @abstractmethod def get_related_language(self) -> str: """Gets the name of the corresponding language.""" pass def get_version_tag(self, version: str) -> str: """Generates a tag based on the version string.""" return version def generate_source_licence_header_template(self) -> str: """Generates the template of the licence header which is put at the top of source files.""" return _generate_generic_licence_header_template() def can_add_licence_headers(self) -> bool: """States whether licence headers can be added.""" return False def can_get_project_metadata(self) -> bool: """States whether project metadata can be retrieved.""" return False def get_secret_registry_exclude_files(self) -> List[str]: """Gets additional detect-secrets exclude patterns for this plugin.""" return list() def should_include_spdx_in_package(self) -> bool: """States whether the SPDX documents should be included in the package.""" return False def should_clean_before_packaging(self) -> bool: """States whether the repository must be cleaned before packaging happens.""" return False def tag_release(self, git: GitWrapper, version: str, shortcuts: Dict[str, bool]) -> None: """Tags release commit.""" logger.info(f"Tagging commit as release {version}") git.create_tag(self.get_version_tag(version), message=f"release {version}") for shortcut, versions in shortcuts.items(): if versions: git.create_tag(self.get_version_tag(shortcut), message=f"{shortcut} release") else: git.create_tag(shortcut, message=shortcut) @abstractmethod def generate_code_documentation(self, output_directory: Path, module_to_document: str) -> None: """Generates the code documentation.""" logger.info("Generating code documentation") pass @abstractmethod def package_software(self, mode: CommitType, version: str) -> None: """Package the software so that it can get released.""" if mode == CommitType.RELEASE: logger.info(f"Generating a release package [{version}]") elif mode == CommitType.BETA: logger.info(f"Generating a pre-release package [{version}]") else: logger.info(f"Generating a development package [{version}]") pass @abstractmethod def release_package_to_repository(self, mode: CommitType, version: str) -> None: """Release the package to the official software repository.""" logger.info(f"Uploading the package [{version}]") pass @abstractmethod def get_current_spdx_project(self, skip_dependency_download: bool = False) -> Optional["SpdxProject"]: """Gets current project SPDX.""" pass def check_credentials(self) -> None: """Checks necessary credentials are set for releasing.""" # Checks the GitHub token is defined configuration.get_value(ConfigurationVariable.GIT_TOKEN)Base class from which language plugins should inherit from.
To write a new language plugin, implement the following methods at a minimum
Ancestors
- abc.ABC
Subclasses
Methods
def can_add_licence_headers(self) ‑> bool-
Expand source code
def can_add_licence_headers(self) -> bool: """States whether licence headers can be added.""" return FalseStates whether licence headers can be added.
def can_get_project_metadata(self) ‑> bool-
Expand source code
def can_get_project_metadata(self) -> bool: """States whether project metadata can be retrieved.""" return FalseStates whether project metadata can be retrieved.
def check_credentials(self) ‑> None-
Expand source code
def check_credentials(self) -> None: """Checks necessary credentials are set for releasing.""" # Checks the GitHub token is defined configuration.get_value(ConfigurationVariable.GIT_TOKEN)Checks necessary credentials are set for releasing.
def generate_code_documentation(self, output_directory: pathlib.Path, module_to_document: str) ‑> None-
Expand source code
@abstractmethod def generate_code_documentation(self, output_directory: Path, module_to_document: str) -> None: """Generates the code documentation.""" logger.info("Generating code documentation") passGenerates the code documentation.
def generate_source_licence_header_template(self) ‑> str-
Expand source code
def generate_source_licence_header_template(self) -> str: """Generates the template of the licence header which is put at the top of source files.""" return _generate_generic_licence_header_template()Generates the template of the licence header which is put at the top of source files.
def get_current_spdx_project(self, skip_dependency_download: bool = False) ‑> SpdxProject | None-
Expand source code
@abstractmethod def get_current_spdx_project(self, skip_dependency_download: bool = False) -> Optional["SpdxProject"]: """Gets current project SPDX.""" passGets current project SPDX.
-
Expand source code
@abstractmethod def get_related_language(self) -> str: """Gets the name of the corresponding language.""" passGets the name of the corresponding language.
def get_secret_registry_exclude_files(self) ‑> List[str]-
Expand source code
def get_secret_registry_exclude_files(self) -> List[str]: """Gets additional detect-secrets exclude patterns for this plugin.""" return list()Gets additional detect-secrets exclude patterns for this plugin.
def get_version_tag(self, version: str) ‑> str-
Expand source code
def get_version_tag(self, version: str) -> str: """Generates a tag based on the version string.""" return versionGenerates a tag based on the version string.
def package_software(self,
mode: CommitType,
version: str) ‑> None-
Expand source code
@abstractmethod def package_software(self, mode: CommitType, version: str) -> None: """Package the software so that it can get released.""" if mode == CommitType.RELEASE: logger.info(f"Generating a release package [{version}]") elif mode == CommitType.BETA: logger.info(f"Generating a pre-release package [{version}]") else: logger.info(f"Generating a development package [{version}]") passPackage the software so that it can get released.
def release_package_to_repository(self,
mode: CommitType,
version: str) ‑> None-
Expand source code
@abstractmethod def release_package_to_repository(self, mode: CommitType, version: str) -> None: """Release the package to the official software repository.""" logger.info(f"Uploading the package [{version}]") passRelease the package to the official software repository.
def should_clean_before_packaging(self) ‑> bool-
Expand source code
def should_clean_before_packaging(self) -> bool: """States whether the repository must be cleaned before packaging happens.""" return FalseStates whether the repository must be cleaned before packaging happens.
def should_include_spdx_in_package(self) ‑> bool-
Expand source code
def should_include_spdx_in_package(self) -> bool: """States whether the SPDX documents should be included in the package.""" return FalseStates whether the SPDX documents should be included in the package.
def tag_release(self,
git: GitWrapper,
version: str,
shortcuts: Dict[str, bool]) ‑> None-
Expand source code
def tag_release(self, git: GitWrapper, version: str, shortcuts: Dict[str, bool]) -> None: """Tags release commit.""" logger.info(f"Tagging commit as release {version}") git.create_tag(self.get_version_tag(version), message=f"release {version}") for shortcut, versions in shortcuts.items(): if versions: git.create_tag(self.get_version_tag(shortcut), message=f"{shortcut} release") else: git.create_tag(shortcut, message=shortcut)Tags release commit.