MCPcopy Create free account
hub / github.com/doldecomp/mkdd / calculate_progress

Function calculate_progress

tools/project.py:1996–2086  ·  view source on GitHub ↗
(config: ProjectConfig)

Source from the content-addressed store, hash-verified

1994
1995# Print progress information from objdiff report
1996def calculate_progress(config: ProjectConfig) -> None:
1997 config.validate()
1998 out_path = config.out_path()
1999 report_path = out_path / "report.json"
2000 if not report_path.is_file():
2001 sys.exit(f"Report file {report_path} does not exist")
2002
2003 report_data: Dict[str, Any] = {}
2004 with open(report_path, "r", encoding="utf-8") as f:
2005 report_data = json.load(f)
2006
2007 # Convert string numbers (u64) to int
2008 def convert_numbers(data: Dict[str, Any]) -> None:
2009 for key, value in data.items():
2010 if isinstance(value, str) and value.isdigit():
2011 data[key] = int(value)
2012
2013 convert_numbers(report_data["measures"])
2014 for category in report_data.get("categories", []):
2015 convert_numbers(category["measures"])
2016
2017 # Output to GitHub Actions job summary, if available
2018 summary_path = os.getenv("GITHUB_STEP_SUMMARY")
2019 summary_file: Optional[IO[str]] = None
2020 if summary_path:
2021 summary_file = open(summary_path, "a", encoding="utf-8")
2022 summary_file.write("```\n")
2023
2024 def progress_print(s: str) -> None:
2025 print(s)
2026 if summary_file:
2027 summary_file.write(s + "\n")
2028
2029 # Print human-readable progress
2030 progress_print("Progress:")
2031
2032 def print_category(name: str, measures: Dict[str, Any]) -> None:
2033 total_code = measures.get("total_code", 0)
2034 matched_code = measures.get("matched_code", 0)
2035 matched_code_percent = measures.get("matched_code_percent", 0)
2036 total_data = measures.get("total_data", 0)
2037 matched_data = measures.get("matched_data", 0)
2038 matched_data_percent = measures.get("matched_data_percent", 0)
2039 total_functions = measures.get("total_functions", 0)
2040 matched_functions = measures.get("matched_functions", 0)
2041 complete_code_percent = measures.get("complete_code_percent", 0)
2042 total_units = measures.get("total_units", 0)
2043 complete_units = measures.get("complete_units", 0)
2044
2045 progress_print(
2046 f" {name}: {matched_code_percent:.2f}% matched, {complete_code_percent:.2f}% linked ({complete_units} / {total_units} files)"
2047 )
2048 progress_print(
2049 f" Code: {matched_code} / {total_code} bytes ({matched_functions} / {total_functions} functions)"
2050 )
2051 progress_print(
2052 f" Data: {matched_data} / {total_data} bytes ({matched_data_percent:.2f}%)"
2053 )

Callers 1

configure.pyFile · 0.90

Calls 10

openFunction · 0.85
convert_numbersFunction · 0.85
progress_printFunction · 0.85
print_categoryFunction · 0.85
validateMethod · 0.80
out_pathMethod · 0.80
loadMethod · 0.45
getMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected