ANSI colors: green, yellow, and red added.

main
Robert 8 months ago
parent 566c11af0e
commit 11a2b3a1a0
  1. 23
      delibs.py
  2. 18
      get_dups.sh

@ -16,6 +16,9 @@ use_ANSI_Colors = True
# ANSI escape codes for colors # ANSI escape codes for colors
WHITE = "\033[97m" WHITE = "\033[97m"
BRIGHT_GREEN = "\033[92m"
BRIGHT_YELLOW = "\033[93m"
BRIGHT_RED = "\033[91m"
RESET = "\033[0m" RESET = "\033[0m"
start = time.perf_counter() start = time.perf_counter()
@ -29,12 +32,25 @@ def exit_handler(signum, frame):
# CTRL+C will Exit NOW!!! # CTRL+C will Exit NOW!!!
signal.signal(signal.SIGINT, exit_handler) signal.signal(signal.SIGINT, exit_handler)
def get_color_for_timer(total):
match total:
case x if x < 1: # 0.x
return BRIGHT_GREEN
case x if 1 <= x <= 7: # Matches 1 to 7
return WHITE
case x if x >= 10:
return BRIGHT_RED
case _:
return BRIGHT_YELLOW #8-9
def exit_timer(level): def exit_timer(level):
end = time.perf_counter() end = time.perf_counter()
total_time = end - start
if use_ANSI_Colors == True: if use_ANSI_Colors == True:
print(f"{WHITE}⏱ Execution took {end - start:.4f} seconds{RESET}") use_color = get_color_for_timer(total_time)
print(f"{use_color}⏱ Execution took {total_time:.4f} seconds{RESET}")
else: else:
print(f"⏱ Execution took {end - start:.4f} seconds") print(f"⏱ Execution took {total_time:.4f} seconds")
exit(level) exit(level)
@ -68,7 +84,8 @@ class Timer:
def print_result(self): def print_result(self):
elapsed = self.elapsed() elapsed = self.elapsed()
if use_ANSI_Colors == True: if use_ANSI_Colors == True:
print(f"{self.name}: {WHITE}{elapsed:.6f} seconds{RESET}") use_color = get_color_for_timer(elapsed)
print(f"{self.name}: {use_color}{elapsed:.6f} seconds{RESET}")
else: else:
print(f"{self.name}: ⏱ {elapsed:.6f} seconds") print(f"{self.name}: ⏱ {elapsed:.6f} seconds")

@ -6,6 +6,8 @@ source myenv/bin/activate
# Remove trailing slash # Remove trailing slash
path="${1%/}" path="${1%/}"
start_time=$(date +%s)
# Check if the first argument is a directory # Check if the first argument is a directory
if [ ! -d "$path" ]; then if [ ! -d "$path" ]; then
echo "Error: '$path' is not a directory." echo "Error: '$path' is not a directory."
@ -75,3 +77,19 @@ for ((i = 0; i < ${#images[@]}; i++)); do
done done
done done
end_time=$(date +%s)
elapsed=$((end_time - start_time))
# Convert to hours, minutes, seconds
hours=$((elapsed / 3600))
minutes=$(( (elapsed % 3600) / 60 ))
seconds=$((elapsed % 60))
printf "Total time to dedup everything: %02d:%02d:%02d\n" $hours $minutes $seconds
if [ "$2" != "forreal" ] && [ -f "dups.txt" ]; then
more dups.txt
else
echo "No Dups found"
fi

Loading…
Cancel
Save