summaryrefslogtreecommitdiff
path: root/progress.py
diff options
context:
space:
mode:
authorElliptic Ellipsis <elliptic.ellipsis@gmail.com>2021-12-09 05:24:45 +0000
committerElliptic Ellipsis <elliptic.ellipsis@gmail.com>2021-12-09 05:24:45 +0000
commitd4fc05d9cc03944ca7918439c8f5dfab50471339 (patch)
treedd63499e82811efe99cd113288df42bded985da9 /progress.py
parent02252b52ce8d883ee7f418be1ba34367575a2fda (diff)
Update progress script with new csv format, text mode, etc.
Diffstat (limited to 'progress.py')
-rwxr-xr-x[-rw-r--r--]progress.py54
1 files changed, 41 insertions, 13 deletions
diff --git a/progress.py b/progress.py
index 512dc31a..141fbc30 100644..100755
--- a/progress.py
+++ b/progress.py
@@ -1,4 +1,7 @@
+#!/usr/bin/env python3
+
import argparse
+import json
import git
import os
import re
@@ -80,9 +83,13 @@ def parse_map(non_matching_funcs):
def main():
parser = argparse.ArgumentParser()
- parser.add_argument('-m', '--matching', dest='matching', action='store_true',
- help='Output matching progress instead of decompilation progress')
+
+ 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")
args = parser.parse_args()
+
matching = args.matching
non_matching_funcs = []
@@ -101,21 +108,42 @@ def main():
total = src + asm
data_total = src_data + data
- src_pct = '%.4f' % (100 * src / total)
- asm_pct = '%.4f' % (100 * asm / total)
+ src_percent = 100 * src / total
+ asm_percent = 100 * asm / total
+
+ src_data_percent = 100 * src_data / data_total
+ data_percent = 100 * data / data_total
+
- src_data_pct = '%.4f' % (100 * src_data / data_total)
- data_pct = '%.4f' % (100 * data / data_total)
+ if args.format == 'csv':
+ version = 2
+ git_object = git.Repo().head.object
+ timestamp = str(git_object.committed_date)
+ git_hash = git_object.hexsha
- 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(src),
+ str(total), str(src_data), str(data_total)]
- csv_list = [str(version), timestamp, git_hash, str(src_pct),
- str(asm_pct), str(src_data_pct), str(data_pct)]
+ print(','.join(csv_list))
- print(','.join(csv_list))
+ elif args.format == 'shield-json':
+ # https://shields.io/endpoint
+ print(json.dumps({
+ "schemaVersion": 1,
+ "label": "progress",
+ "message": f"{src_percent:.3g}%",
+ "color": 'yellow',
+ }))
+
+ elif args.format == 'text':
+ adjective = "decompiled" if not args.matching else "matched"
+
+ print("src: {:>9} / {:>8} total bytes {:<10} {:>9.4f}%".format(src, total, adjective, round(src_percent, 4)))
+ # print()
+ print("data: {:>9} / {:>8} total bytes analysed {:>9.4f}%".format(src_data, data_total, round(src_data_percent, 4)))
+
+ else:
+ print("Unknown format argument: " + args.format)
if __name__ == '__main__':