Skip to content

Commit 154c034

Browse files
committed
Minor tweaks
1 parent 7c4037c commit 154c034

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
*.html
22
ads.txt
3+
34
.DS_Store
45
build_ebook.log
56
temp_ebook.md
7+
**/_out/*

build_ebook_v2.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import pathlib
44
import re
5+
import shutil
56
import subprocess
67

78

@@ -209,13 +210,17 @@ def _process_files_in_directory(
209210

210211
if __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)

0 commit comments

Comments
 (0)