From e023857c19318640bb5c69aa147fee82a30d4121 Mon Sep 17 00:00:00 2001 From: Karlo Blazevic <64852856+VanLaareN@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:55:57 +0100 Subject: [PATCH] removed readme code and used static generator instead (#43) --- FileGenerator.py | 37 +++++-------------------------------- 1 file changed, 5 insertions(+), 32 deletions(-) diff --git a/FileGenerator.py b/FileGenerator.py index 7631b19..7cc7a11 100644 --- a/FileGenerator.py +++ b/FileGenerator.py @@ -57,38 +57,6 @@ def generate_precice_config(self) -> None: return self.logger.success(f"XML generation completed successfully: {target}") - - def generate_README(self) -> None: - """Generates the README.md file""" - try: - origin_template_README = Path(__file__).parent / "templates" / "template_README.md" - self.logger.info("Reading in the template file for README.md") - - # Check if the template file exists - if not origin_template_README.exists(): - raise FileNotFoundError(f"Template file not found: {origin_template_README}") - - # Read the template content - template_content = origin_template_README.read_text(encoding="utf-8") - - # Set the target for the README.md - target = self.structure.README - - self.logger.info(f"Writing the template to the target: {str(target)}") - - # Write content to the target file - with open(target, 'w', encoding="utf-8") as README: - README.write(template_content) - - self.logger.success(f"Successfully written README.md content to: {str(target)}") - - except FileNotFoundError as fileNotFoundException: - self.logger.error(f"File not found: {fileNotFoundException}") - except PermissionError as premissionErrorException: - self.logger.error(f"Permission error: {premissionErrorException}") - except Exception as generalExcpetion: - self.logger.error(f"An unexpected error occurred: {generalExcpetion}") - def _generate_static_files(self, target: Path, name: str) -> None: """Generate static files from templates @@ -121,6 +89,11 @@ def _generate_static_files(self, target: Path, name: str) -> None: self.logger.error(f"An unexpected error occurred: {generalExcpetion}") pass + def generate_README(self) -> None: + """Generates the README.md file""" + self._generate_static_files(target=self.structure.README, + name="README.md") + def generate_run(self) -> None: """Generates the run.sh file""" self._generate_static_files(target=self.structure.run,