def delete()

in source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/tools/cleaner.py [0:0]


    def delete(self, source_dir):
        source_path = Path(source_dir)

        for path in source_path.rglob(self.pattern):
            if "aws_solutions" not in str(
                path.name
            ):  # prevent the module from being unlinked in a dev environment
                if self.file_type == "d" and path.is_dir():
                    logger.info(f"deleting {self.name} directory {path}")
                    shutil.rmtree(path, ignore_errors=True)
                if self.file_type == "f" and path.is_file():
                    logger.info(f"deleting {self.name} file {path}")
                    try:
                        path.unlink()
                    except FileNotFoundError:
                        pass