Skip to content

Commit

Permalink
display improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
janiko71 committed Feb 20, 2024
1 parent 21cc4a2 commit d847354
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions dir_bcdecryptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ def decrypt_file(filename):
# Read the 1st block (header), not used here
f_in.read(offset)

overall_progression = nb_decrypted_files / nb_encrypted_files * 100

# Now read all the encrypted blocks
for block_nb in range (1, nb_blocks + 1):

Expand All @@ -170,14 +172,15 @@ def decrypt_file(filename):

# Padding exception for the last block
progression = (block_nb / nb_blocks * 100)
overall_progression = nb_decrypted_files / nb_encrypted_files * 100

helper.display_progression(encrypted_data_filename[:-3], block_nb, progression, overall_progression)
if (block_nb == nb_blocks):
decrypted_block = decrypted_block[:-data_file.cipher_padding_length]
f_out.write(decrypted_block)

nb_decrypted_files = nb_decrypted_files + 1
helper.display_progression(encrypted_data_filename[:-3], block_nb, progression, overall_progression)
overall_progression = nb_decrypted_files / nb_encrypted_files * 100
helper.display_progression(encrypted_data_filename[:-3], nb_blocks + 1, 100, overall_progression)

f_in.close
f_out.close()
Expand Down
4 changes: 2 additions & 2 deletions res/fnhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ def traverse_directory(filepath, extension=".bc"):
def display_progression(filename, block_nb, progression, overall_progression):

terminal_size = shutil.get_terminal_size()
format_txt = Fore.LIGHTWHITE_EX + "{}" + Fore.RESET + ", Fileblock #{}, file progression {:6.2f} %, overall progession {:6.2f} %"
displayed_text = format_txt.format(filename, block_nb, progression, overall_progression)
format_txt = "overall progession {:6.2f} %, file " + Fore.LIGHTWHITE_EX + "{}" + Fore.RESET + ", fileblock #{}, file progression {:6.2f} %"
displayed_text = format_txt.format(overall_progression, filename, block_nb, progression)
reset_text = " " * max(0, terminal_size.columns - len(displayed_text))
print(displayed_text + reset_text, end="\r", flush=True)

Expand Down

0 comments on commit d847354

Please sign in to comment.