File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11* .html
22ads.txt
3+
34.DS_Store
45build_ebook.log
56temp_ebook.md
7+ ** /_out /*
Original file line number Diff line number Diff line change 22
33import pathlib
44import re
5+ import shutil
56import subprocess
67
78
@@ -209,13 +210,17 @@ def _process_files_in_directory(
209210
210211if __name__ == "__main__" :
211212
212- log = VTLogger ("./build_ebook.log" )
213+ out_dir = pathlib .Path ("./_out" )
214+ if not out_dir .exists ():
215+ out_dir .mkdir ()
216+
217+ log = VTLogger (f"{ out_dir .as_posix ()} /build_ebook.log" )
213218 eBookBuilder = VTEBookBuilder (log )
214219
215220 generated_pngs = eBookBuilder .convert_svg_to_png ("./images" )
216221
217222 LANGUAGES = [ "en" , "fr" ]
218- OUTPUT_FILENAME = pathlib .Path (". /temp_ebook.md" )
223+ OUTPUT_FILENAME = pathlib .Path (f" { out_dir . as_posix () } /temp_ebook.md" )
219224
220225 for lang in LANGUAGES :
221226 lang = f"./{ lang } "
@@ -226,11 +231,16 @@ def _process_files_in_directory(
226231 # eBookBuilder.build_pdf_book(lang)
227232
228233 # Clean up
229- OUTPUT_FILENAME .unlink ()
234+ if OUTPUT_FILENAME .exists ():
235+ OUTPUT_FILENAME .unlink ()
230236
231237 # Clean up temporary files
232238 for png_path in generated_pngs :
233239 try :
234240 png_path .unlink ()
235241 except FileNotFoundError as fileError :
236242 log .error (fileError )
243+
244+ # Comment to view log
245+ if out_dir .exists ():
246+ shutil .rmtree (out_dir )
You can’t perform that action at this time.
0 commit comments