summaryrefslogtreecommitdiff
path: root/progress.py
diff options
context:
space:
mode:
authorcoco875 <59367621+coco875@users.noreply.github.com>2024-04-13 02:54:59 +0200
committerGitHub <noreply@github.com>2024-04-12 18:54:59 -0600
commite2c19fd4bc8e5f7db8e64629491b80a63c53ee98 (patch)
tree616962007475725799158741c69c453429a989ed /progress.py
parent2d3278d0735386c37b37691dadfaee0dd687d76d (diff)
use github actions instead (#605)
* Create actions
Diffstat (limited to 'progress.py')
-rw-r--r--progress.py52
1 files changed, 47 insertions, 5 deletions
diff --git a/progress.py b/progress.py
index 734d61d7f..b1785cd6a 100644
--- a/progress.py
+++ b/progress.py
@@ -5,10 +5,11 @@ import json
import csv
import os
import re
+from pybadges import badge
# Script arguments.
parser = argparse.ArgumentParser(description="Computes current progress throughout the whole project.")
-parser.add_argument("format", nargs="?", default="text", choices=["text", "verbose", "totalBadge", "gameBadge", "mainBadge", "endingBadge", "racingBadge", "audioBadge", "osBadge", "bytesToDecompile", "globalAsmFuncs", "m2cFuncs", "nonmatchingFuncs"])
+parser.add_argument("format", nargs="?", default="text", choices=["text", "verbose", "totalBadge", "gameBadge", "mainBadge", "endingBadge", "racingBadge", "audioBadge", "osBadge", "bytesToDecompile", "globalAsmFuncs", "m2cFuncs", "nonmatchingFuncs", "badge"])
parser.add_argument("-d", "--debug", dest='debug', action='store_true',
help="Adds additional debug information, outputs files parsed and score for each file")
parser.add_argument("-n", "--nonmatching", dest='nonmatching', action='store_true',
@@ -24,7 +25,7 @@ def GetNonMatchingFunctions(files):
functions = []
for file in files:
- with open(file) as f:
+ with open(file, encoding="utf-8") as f:
functions += re.findall(NON_MATCHING_FUNC_PATTERN, f.read(), re.DOTALL)
functions += re.findall(NON_MATCHING_PRAGMA_PATTERN, f.read(), re.DOTALL)
@@ -38,7 +39,7 @@ def CountMipsToCFunctions(files):
functions = []
for file in files:
- with open(file) as f:
+ with open(file, encoding="utf-8") as f:
functions += re.findall(MIPS_TO_C_FUNC_PATTERN, f.read(), re.DOTALL)
return functions
@@ -51,7 +52,7 @@ def CountGlobalAsmFunctions(files):
functions = []
for file in files:
- with open(file) as f:
+ with open(file, encoding="utf-8") as f:
functions += re.findall(GLOBAL_ASM_FUNC_PATTERN, f.read(), re.DOTALL)
return functions
@@ -65,7 +66,7 @@ def GetCFunctions(files):
functions = []
for file in files:
- with open(file) as f:
+ with open(file, encoding="utf-8") as f:
source_code = f.read()
# Parse regex pattern
@@ -523,5 +524,46 @@ elif args.format == 'verbose':
print(str(segRacing) + "/" + str(seg_racing_size) + " bytes " + adjective + " in segRacing " + str(segRacingPct) + "%")
print(str(audio) + "/" + str(audio_size) + " bytes " + adjective + " in audio " + str(audioPct) + "%")
print(str(libultra) + "/" + str(libultra_size) + " bytes " + adjective + " in libultra " + str(libultraPct) + "%\n")
+
+elif args.format == 'badge':
+ adjective = "decompiled" if args.nonmatching else "matched"
+
+ badge_size_left = badge(left_text="Size left", right_text=str(remaining_size), right_color="blue")
+ with open("docs/html/size_left.svg", "w") as f:
+ f.write(badge_size_left)
+ badge_total_size = badge(left_text="Total size", right_text=str(total_code_size), right_color="blue")
+ with open("docs/html/total_size.svg", "w") as f:
+ f.write(badge_total_size)
+ badge_total_pct = badge(left_text="Total progress", right_text=str(round(totalPct, 2))+"%", right_color="green")
+ with open("docs/html/total_progress.svg", "w") as f:
+ f.write(badge_total_pct)
+ badge_game_pct = badge(left_text="Game progress", right_text=str(round(gamePct, 2))+"%", right_color="green")
+ with open("docs/html/game_progress.svg", "w") as f:
+ f.write(badge_game_pct)
+ badge_asm_funcs = badge(left_text="ASM functions", right_text=str(TotalGlobalAsmFunctions), right_color="blue")
+ with open("docs/html/asm_funcs.svg", "w") as f:
+ f.write(badge_asm_funcs)
+ badge_nonmatching_funcs = badge(left_text="NON_MATCHING functions", right_text=str(TotalNonMatchingFunctions), right_color="blue")
+ with open("docs/html/nonmatching_funcs.svg", "w") as f:
+ f.write(badge_nonmatching_funcs)
+ badge_m2c_funcs = badge(left_text="MIPS_TO_C functions", right_text=str(TotalMipsToCFunctions), right_color="blue")
+ with open("docs/html/m2c_funcs.svg", "w") as f:
+ f.write(badge_m2c_funcs)
+ badge_seg_main = badge(left_text="Main progress", right_text=str(round(segMainPct, 2))+"%", right_color="green")
+ with open("docs/html/seg_main_progress.svg", "w") as f:
+ f.write(badge_seg_main)
+ badge_seg_ending = badge(left_text="Ending progress", right_text=str(round(segEndingPct, 2))+"%", right_color="green")
+ with open("docs/html/seg_ending_progress.svg", "w") as f:
+ f.write(badge_seg_ending)
+ badge_seg_racing = badge(left_text="Racing progress", right_text=str(round(segRacingPct, 2))+"%", right_color="green")
+ with open("docs/html/seg_racing_progress.svg", "w") as f:
+ f.write(badge_seg_racing)
+ badge_audio = badge(left_text="Audio progress", right_text=str(round(audioPct, 2))+"%", right_color="green")
+ with open("docs/html/audio_progress.svg", "w") as f:
+ f.write(badge_audio)
+ badge_libultra = badge(left_text="Libultra progress", right_text=str(round(libultraPct, 2))+"%", right_color="green")
+ with open("docs/html/libultra_progress.svg", "w") as f:
+ f.write(badge_libultra)
+
else:
print("Unknown format argument: " + args.format)