def _create_failed_packs_report(lint_status: dict, path: str): """ Creates and saves a file containing all lint failed packs :param lint_status: dict Dictionary containing type of failures and corresponding failing tests. Looks like this: lint_status = { "fail_packs_flake8": [], "fail_packs_bandit": [], "fail_packs_mypy": [], "fail_packs_vulture": [], "fail_packs_pylint": [], "fail_packs_pytest": [], "fail_packs_pwsh_analyze": [], "fail_packs_pwsh_test": [], "fail_packs_image": [] } :param path: str The path to save the report. """ failed_ut: set = set() for key in lint_status: if key.startswith('fail'): failed_ut = failed_ut.union(lint_status[key]) if path and failed_ut: file_path = Path(path) / "failed_lint_report.txt" file_path.write_text('\n'.join(failed_ut))
def modify_common_server_constants(code_path: Path, content_version: str, branch_name: Optional[str] = None): """ Modify content/Packs/Base/Scripts/CommonServerPython.py global variables: a. CONTENT_RELEASE_VERSION to given content version flag. b. CONTENT_BRANCH_NAME to active branch Args: code_path: Packs/Base/Scripts/CommonServerPython.py full code path. branch_name: branch name to update in CONTENT_BRANCH_NAME content_version: content version to update in CONTENT_RELEASE_VERSION """ file_content_new = re.sub(r"CONTENT_RELEASE_VERSION = '\d.\d.\d'", f"CONTENT_RELEASE_VERSION = '{content_version}'", code_path.read_text()) file_content_new = re.sub(r"CONTENT_BRANCH_NAME = '\w+'", f"CONTENT_BRANCH_NAME = '{branch_name}'", file_content_new) code_path.write_text(file_content_new)
def _create_failed_packs_report(lint_status: dict, path: str): """ Creates and saves a file containing all lint failed packs :param lint_status: dict Dictionary containing type of failures and corresponding failing tests. Looks like this: lint_status = { "fail_packs_flake8": [], "fail_packs_bandit": [], "fail_packs_mypy": [], "fail_packs_vulture": [], "fail_packs_pylint": [], "fail_packs_pytest": [], "fail_packs_pwsh_analyze": [], "fail_packs_pwsh_test": [], "fail_packs_image": [] } :param path: str The path to save the report. """ failed_ut: Set[Any] = set().union( [second_val for val in lint_status.values() for second_val in val]) if path and failed_ut: file_path = Path(path) / "failed_lint_report.txt" file_path.write_text('\n'.join(failed_ut))