aboutsummaryrefslogtreecommitdiff
path: root/gn3/computations/diff.py
blob: af02f7fb1503c6e79e263135769e7a905e256cd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
"""This module contains code that's used for generating diffs"""
from typing import Optional

from gn3.commands import run_cmd


def generate_diff(data: str, edited_data: str) -> Optional[str]:
    """Generate the diff between 2 files"""
    results = run_cmd(f"diff {data} {edited_data}", success_codes=(1, 2))
    if results.get("code", -1) > 0:
        return results.get("output")
    return None