Skip to content

Commit

Permalink
Actually do the diff in generate_function_diff
Browse files Browse the repository at this point in the history
  • Loading branch information
roblabla committed Dec 31, 2023
1 parent 92bfd9b commit b98a96f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion scripts/generate_function_diff.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python

import difflib
from pathlib import Path
import sys
import os
Expand Down Expand Up @@ -55,7 +56,27 @@ def generate_function_diff(fn_name):

def main():
fn_name = sys.argv[1]
generate_function_diff(fn_name)
orig, reimpl = generate_function_diff(fn_name)

base_dir = Path(__file__).parent.parent
diff_dir = base_dir / "diff"
fs_fn_name = fn_name.replace(":", "__")

diff = "\n".join(
difflib.unified_diff(
orig.split("\n"),
reimpl.split("\n"),
"Original",
"Reimplementation",
n=20,
lineterm="",
)
)

print(diff)

with open(diff_dir / fs_fn_name / "diff.diff", "w") as f:
f.write(diff)


if __name__ == "__main__":
Expand Down

0 comments on commit b98a96f

Please sign in to comment.