mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-23 09:03:22 -05:00
fix(tools): write progress history files with utf-8 encoding
This commit is contained in:
1 parent
b7d1d47a5f
commit
b4c6da5c07
2 files changed
+28
-8
No files matched your search
@@ -26,7 +26,7 @@ def git(*args):
|
||||
|
||||
def daily_commits(ref):
|
||||
seen = {}
|
||||
for line in git("log", "--first-parent", "--format=%H %ct", ref).decode().splitlines():
|
||||
for line in git("log", "--first-parent", "--format=%H %ct", ref).decode("utf-8").splitlines():
|
||||
sha, timestamp = line.split()
|
||||
seen.setdefault(datetime.fromtimestamp(int(timestamp), timezone.utc).date().isoformat(), sha)
|
||||
return sorted(seen.items())
|
||||
@@ -221,12 +221,12 @@ def page(points):
|
||||
]) + "\n"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main(argv=None):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("output", type=Path)
|
||||
parser.add_argument("--ref", default="HEAD", help="branch or commit whose first-parent history is measured")
|
||||
parser.add_argument("--cache", type=Path, help="reuse per-commit counts while the scanner, ISA list and Python version match")
|
||||
args = parser.parse_args()
|
||||
args = parser.parse_args(argv)
|
||||
try:
|
||||
if args.cache:
|
||||
outputs = [args.output / name for name in ("history.json", "history.svg", "history.html")]
|
||||
@@ -239,7 +239,11 @@ if __name__ == "__main__":
|
||||
if not points:
|
||||
parser.error("no commit with a measurable tree")
|
||||
args.output.mkdir(parents=True, exist_ok=True)
|
||||
(args.output / "history.json").write_text(json.dumps(points, indent=2))
|
||||
(args.output / "history.svg").write_text(chart(points) + "\n")
|
||||
(args.output / "history.html").write_text(page(points))
|
||||
(args.output / "history.json").write_text(json.dumps(points, indent=2), encoding="utf-8")
|
||||
(args.output / "history.svg").write_text(chart(points) + "\n", encoding="utf-8")
|
||||
(args.output / "history.html").write_text(page(points), encoding="utf-8")
|
||||
print(f"{len(points)} days, {points[0]['date']} .. {points[-1]['date']}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,3 +1,4 @@
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -17,9 +18,9 @@ OPCODES = Path("core/shader/recompiler/RdnaDecoder/include/RdnaDecoder/RdnaOpcod
|
||||
def commit(root, day, message, body, time="12:00:00Z"):
|
||||
library = root / "core/libs/prx/libSceExample"
|
||||
library.mkdir(parents=True, exist_ok=True)
|
||||
(library / "Export.cpp").write_text(body)
|
||||
(library / "Export.cpp").write_text(body, encoding="utf-8")
|
||||
(root / OPCODES).parent.mkdir(parents=True, exist_ok=True)
|
||||
(root / OPCODES).write_text("enum class RdnaOpcode : int {\n SEndpgm,\n};\n")
|
||||
(root / OPCODES).write_text("enum class RdnaOpcode : int {\n SEndpgm,\n};\n", encoding="utf-8")
|
||||
env = {**os.environ, "GIT_AUTHOR_DATE": f"{day}T{time}", "GIT_COMMITTER_DATE": f"{day}T{time}"}
|
||||
subprocess.run(["git", "-C", str(root), "add", "-A"], check=True)
|
||||
subprocess.run(["git", "-C", str(root), "-c", "user.name=t", "-c", "user.email=t@t", "commit", "-q", "-m", message],
|
||||
@@ -140,6 +141,21 @@ class ProgressHistoryTests(unittest.TestCase):
|
||||
for label in ("Aug 3", "Aug 10", "Aug 17", "Aug 24", "Aug 31"):
|
||||
self.assertIn(f">{label}<", svg)
|
||||
|
||||
def test_main_writes_utf8_output_files(self):
|
||||
point = {"date": "2026-01-01", "commit": "abc1234",
|
||||
"libraries": {"done": 1, "total": 2, "percent": 50.0},
|
||||
"shaders": {"done": 3, "total": 4, "percent": 75.0}}
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
output = Path(directory) / "site"
|
||||
with patch.object(progress_history, "collect", return_value=[point]):
|
||||
progress_history.main([str(output)])
|
||||
svg = (output / "history.svg").read_text(encoding="utf-8")
|
||||
self.assertIn("\u25cf", svg)
|
||||
html = (output / "history.html").read_text(encoding="utf-8")
|
||||
self.assertIn("<!DOCTYPE html>", html)
|
||||
data = json.loads((output / "history.json").read_text(encoding="utf-8"))
|
||||
self.assertEqual(data, [point])
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user