Skip to content

Commit

Permalink
[ftcli utils]: modified output of 'rebuild' command (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
ftCLI authored Sep 6, 2023
1 parent 4f2d812 commit 2f15f40
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions foundryToolsCLI/CLI/ftcli_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import tempfile
import time
from copy import deepcopy
from pathlib import Path

Expand Down Expand Up @@ -259,12 +260,19 @@ def rebuild(
if not initial_check_pass(fonts=fonts, output_dir=output_dir):
return

for font in fonts:
rebuilt_files_count = 0
start_time = time.time()

for count, font in enumerate(fonts, start=1):
try:
t = time.time()
file = Path(font.reader.file.name)
output_file = Path(makeOutputFileName(file, outputDir=output_dir, overWrite=overwrite))
flavor = font.flavor

print()
generic_info_message(f"Rebuilding file {count} of {len(fonts)}: {file.name}")

fd, xml_file = tempfile.mkstemp()
os.close(fd)
font.saveXML(xml_file)
Expand All @@ -274,14 +282,23 @@ def rebuild(
rebuilt_font.flavor = flavor
rebuilt_font.save(output_file)

generic_info_message(f"Elapsed time: {round(time.time() - t, 3)} seconds")
file_saved_message(output_file)
os.remove(xml_file)
rebuilt_files_count += 1

if os.path.exists(xml_file):
os.remove(xml_file)

except Exception as e:
generic_error_message(e)
finally:
font.close()

print()
generic_info_message(f"Total files : {len(fonts)}")
generic_info_message(f"Converted files : {rebuilt_files_count}")
generic_info_message(f"Elapsed time : {round(time.time() - start_time, 3)} seconds")


@utils.command()
@add_file_or_path_argument()
Expand Down

0 comments on commit 2f15f40

Please sign in to comment.