Skip to content

Commit

Permalink
fix in case program is not run directly
Browse files Browse the repository at this point in the history
  • Loading branch information
jooleer authored May 10, 2023
1 parent 8bc4bf9 commit 8b0821b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions folder_hash_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,19 @@ def get_files_amount(folder_path):
def folder_generate_hashes(folder_path):
folder_hashes = {}
for file_path in get_all_files(folder_path):
file_hash = generate_file_hash(file_path, hash_algorithm)
#in case program is not run directly
if __name__ == '__main__':
file_hash = generate_file_hash(file_path, hash_algorithm)
else:
file_hash = generate_file_hash(file_path, "CRC32")
relative_path = os.path.relpath(file_path, folder_path)
folder_hashes[relative_path] = file_hash
if(args.verbose):
print(f"Generated hash for: {file_path} [{file_hash}]")
if(not args.logging):
logging.info(f"[HASH]: {file_path} -> {file_hash}")
# in case program is not run directly
if __name__ == '__main__':
if(args.verbose):
print(f"Generated hash for: {file_path} [{file_hash}]")
if(not args.logging):
logging.info(f"[HASH]: {file_path} -> {file_hash}")
return folder_hashes

# convert seconds to hours, minutes, seconds
Expand Down

0 comments on commit 8b0821b

Please sign in to comment.