diff options
| author | Roman971 <32455037+Roman971@users.noreply.github.com> | 2021-02-11 13:10:05 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-11 07:10:05 -0500 |
| commit | f95a5aec6820c5e564b65f41e2557b02b2dd59a3 (patch) | |
| tree | f2255d51cb7bac354263444a8dce8b74234168c4 /progress.py | |
| parent | ec31611c0ef39066ad2c03f1debd037b444af1ea (diff) | |
Various README updates (#671)
* Update README
* Add shields.io badges in the README
* Add a mention about shiftability in README
* Fix shield json command in JenkinsFile
* Improve progress badge formatting
Now it should show the percentage as 51.2% instead of 51.17%, and 100% instead of 100.00%
Diffstat (limited to 'progress.py')
| -rwxr-xr-x | progress.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/progress.py b/progress.py index cdba597df..fd6f5d58e 100755 --- a/progress.py +++ b/progress.py @@ -1,16 +1,16 @@ #!/usr/bin/env python3 import argparse +import json import csv import git import os import re parser = argparse.ArgumentParser(description="Computes current progress throughout the whole project.") +parser.add_argument("format", nargs="?", default="text", choices=["text", "csv", "shield-json"]) parser.add_argument("-m", "--matching", dest='matching', action='store_true', help="Output matching progress instead of decompilation progress") -parser.add_argument("-c", "--csv", dest="csv", action="store_true", - help="Output results in CSV format") args = parser.parse_args() NON_MATCHING_PATTERN = r"#ifdef\s+NON_MATCHING.*?#pragma\s+GLOBAL_ASM\s*\(\s*\"(.*?)\"\s*\).*?#endif" @@ -114,14 +114,22 @@ ovlPct = 100 * ovl / ovlSize compiled_bytes = total bytesPerHeartPiece = compiled_bytes / 80 -if args.csv: +if args.format == 'csv': version = 1 git_object = git.Repo().head.object timestamp = str(git_object.committed_date) git_hash = git_object.hexsha csv_list = [str(version), timestamp, git_hash, str(code), str(codeSize), str(boot), str(bootSize), str(ovl), str(ovlSize), str(src), str(asm), str(len(nonMatchingFunctions))] print(",".join(csv_list)) -else: +elif args.format == 'shield-json': + # https://shields.io/endpoint + print(json.dumps({ + "schemaVersion": 1, + "label": "progress", + "message": f"{srcPct:.3g}%", + "color": 'yellow', + })) +elif args.format == 'text': adjective = "decompiled" if not args.matching else "matched" print(str(total) + " total bytes of decompilable code\n") @@ -138,3 +146,5 @@ else: print("You have " + str(heartPieces) + "/80 heart pieces and " + str(rupees) + " rupee(s).\n") else: print("You have " + str(heartPieces) + "/80 heart pieces.\n") +else: + print("Unknown format argument: " + args.format) |
