| 18 | |
| 19 | |
| 20 | def calculate_diff(params): |
| 21 | diff_tool, new, old, out = params["tool"], params["new"], params["old"], params["out"] |
| 22 | |
| 23 | if not new.exists(): |
| 24 | return Status.NO_NEW_VERSION, params |
| 25 | |
| 26 | if not old.exists(): |
| 27 | return Status.NO_OLD_VERSION, params |
| 28 | |
| 29 | status = Status.OK |
| 30 | if out.exists(): |
| 31 | status = Status.NOTHING_TO_DO |
| 32 | else: |
| 33 | res = subprocess.run([diff_tool.as_posix(), "make", old, new, out]) |
| 34 | if res.returncode != 0: |
| 35 | return Status.INTERNAL_ERROR, params |
| 36 | |
| 37 | diff_size = out.stat().st_size |
| 38 | new_size = new.stat().st_size |
| 39 | |
| 40 | if diff_size > new_size: |
| 41 | status = Status.TOO_LARGE |
| 42 | |
| 43 | params.update({ |
| 44 | "diff_size": diff_size, |
| 45 | "new_size": new_size |
| 46 | }) |
| 47 | |
| 48 | return status, params |
| 49 | |
| 50 | |
| 51 | def mwm_diff_calculation(data_dir, logger, depth): |