#!/usr/bin/python3 import re import typing as T from dataclasses import dataclass from pathlib import Path MAX_X = 50 SQUARE_SIZE = 10 TEXT_SIZE = 15 SQUARE_MARGIN = 2 DOCS_DIR = Path(__file__).parent PROGRESS_TXT_FILE = DOCS_DIR / "progress.txt" PROGRESS_SVG_FILE = DOCS_DIR / "progress.svg" @dataclass class Function: name: str offset: int size: int flags: str @property def decompiled(self): return "+" in self.flags def collect_functions() -> T.Iterable[Function]: for line in PROGRESS_TXT_FILE.open(): if line.startswith("#"): continue func_name, offset, size, flags = re.split(r"\s+", line.strip()) yield Function( name=func_name, offset=int(offset, 16), size=int(size, 16), flags=flags, ) def main() -> None: functions = list(collect_functions()) svg_width = ( min(MAX_X, len(functions)) * (SQUARE_SIZE + SQUARE_MARGIN) + SQUARE_MARGIN ) svg_height = ( ((len(functions) + MAX_X - 1) // MAX_X) * (SQUARE_SIZE + SQUARE_MARGIN) + SQUARE_MARGIN * 2 + TEXT_SIZE * 2 ) with PROGRESS_SVG_FILE.open("w") as handle: print( f'', file=handle, ) for i, function in enumerate(functions): x = (i % MAX_X) * (SQUARE_SIZE + SQUARE_MARGIN) y = (i // MAX_X) * (SQUARE_SIZE + SQUARE_MARGIN) color = "green" if function.decompiled else "pink" print( f"', file=handle, ) y += SQUARE_SIZE y += TEXT_SIZE ready_functions = sum(function.decompiled for function in functions) total_functions = len(functions) ready_size = sum( function.size for function in functions if function.decompiled ) total_size = sum(function.size for function in functions) print( f'' f'Functions decompiled (count): ' f'{ready_functions/total_functions:.02%}' f'', file=handle, ) y += TEXT_SIZE + SQUARE_MARGIN print( f'' f'Functions decompiled (bytesize): {ready_size/total_size:.02%}' f'', file=handle, ) print("", file=handle) if __name__ == "__main__": main()