Skip to content

Commit

Permalink
Added utf-8
Browse files Browse the repository at this point in the history
  • Loading branch information
MartenBE committed Dec 5, 2024
1 parent c316279 commit be42354
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/mkslides/markupgenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def __process_markdown_file(
revealjs_config=OmegaConf.to_container(revealjs_config),
plugins=plugins,
)
self.__create_file(output_markup_path, markup)
self.__create_or_overwrite_file(output_markup_path, markup)

# Copy local files

Expand Down Expand Up @@ -268,7 +268,7 @@ def __process_markdown_directory(self, md_root_path: Path) -> None:
slideshows=slideshows,
build_datetime=datetime.datetime.now(tz=datetime.timezone.utc),
)
self.__create_file(index_path, content)
self.__create_or_overwrite_file(index_path, content)

def __copy_local_files(
self,
Expand Down Expand Up @@ -350,14 +350,14 @@ def __copy_favicon(self, file_using_favicon_path: Path, favicon: str) -> Path |

################################################################################

def __create_file(self, destination_path: Path, content: Any) -> None:
if destination_path.exists():
destination_path.write_text(content)
logger.debug(f"Overwritten: '{destination_path}'")
else:
destination_path.parent.mkdir(parents=True, exist_ok=True)
destination_path.write_text(content)
logger.debug(f"Created file '{destination_path}'")
def __create_or_overwrite_file(self, destination_path: Path, content: Any) -> None:
is_overwrite = destination_path.exists()

destination_path.parent.mkdir(parents=True, exist_ok=True)
destination_path.write_text(content, encoding="utf-8")

action = "Overwritten" if is_overwrite else "Created"
logger.debug(f"{action} file '{destination_path}'")

def __copy_to_output(self, source_path: Path, destination_path: Path) -> Path:
self.__copy(source_path, destination_path)
Expand Down

0 comments on commit be42354

Please sign in to comment.