From 9aacce607d74d34d0a8ced7946b5154baebe5a5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 1 Nov 2020 14:57:05 +0100 Subject: [PATCH] tools: Reformat progress --- tools/progress.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/progress.py b/tools/progress.py index 387c565e..f18819ca 100755 --- a/tools/progress.py +++ b/tools/progress.py @@ -16,12 +16,14 @@ parser.add_argument("--print-ok", "-m", action="store_true", help="Print matching functions") args = parser.parse_args() + class AIClassType(enum.Enum): Action = 0 AI = 1 Behavior = 2 Query = 3 + code_size_total = 0 num_total = 0 code_size: tp.DefaultDict[FunctionStatus, int] = defaultdict(int) @@ -64,7 +66,8 @@ for info in utils.get_functions(): if args.print_ok: print(f"{Fore.GREEN}OK{Fore.RESET} {utils.format_symbol_name(info.decomp_name)}") elif info.status == FunctionStatus.Wip: - print(f"{Back.RED}{Style.BRIGHT}{Fore.WHITE} WIP {Style.RESET_ALL} {utils.format_symbol_name(info.decomp_name)}{Style.RESET_ALL}") + print( + f"{Back.RED}{Style.BRIGHT}{Fore.WHITE} WIP {Style.RESET_ALL} {utils.format_symbol_name(info.decomp_name)}{Style.RESET_ALL}") def format_progress(label: str, num: int, size: int): @@ -72,19 +75,24 @@ def format_progress(label: str, num: int, size: int): size_percentage = round(100 * size / code_size_total, 3) return f"{num:>7d} {label}{Fore.RESET} ({percentage}% | size: {size_percentage}%)" + def format_progress_for_status(label: str, status: FunctionStatus): return format_progress(label, counts[status], code_size[status]) + def format_ai_progress(label: str, class_type: AIClassType): percentage = round(100 * ai_counts_done[class_type] / ai_counts[class_type], 3) return f"{ai_counts_done[class_type]:>7d} {label}{Fore.RESET} ({percentage}%)" + print() print(f"{num_total:>7d} functions (size: ~{code_size_total} bytes)") -count_decompiled = counts[FunctionStatus.Matching] + counts[FunctionStatus.Equivalent] + counts[FunctionStatus.NonMatching] -code_size_decompiled = code_size[FunctionStatus.Matching] + code_size[FunctionStatus.Equivalent] + code_size[FunctionStatus.NonMatching] +count_decompiled = counts[FunctionStatus.Matching] + counts[FunctionStatus.Equivalent] + counts[ + FunctionStatus.NonMatching] +code_size_decompiled = code_size[FunctionStatus.Matching] + code_size[FunctionStatus.Equivalent] + code_size[ + FunctionStatus.NonMatching] print(format_progress(f"{Fore.CYAN}decompiled", count_decompiled, code_size_decompiled)) print(format_progress_for_status(f"{Fore.GREEN}matching", FunctionStatus.Matching))