|
1 | 1 | import sys
|
2 | 2 | import filecmp
|
3 |
| -import difflib |
4 |
| - |
5 |
| - |
6 |
| -def show_diff(file1, file2): |
7 |
| - with open(file1, "r") as f1, open(file2, "r") as f2: |
8 |
| - lines1 = f1.readlines() |
9 |
| - lines2 = f2.readlines() |
10 |
| - |
11 |
| - diff = difflib.unified_diff(lines1, lines2, lineterm="") |
12 |
| - |
13 |
| - for line in diff: |
14 |
| - print(line) |
| 3 | +import shutil |
15 | 4 |
|
16 | 5 |
|
17 | 6 | def main(argv=None):
|
18 | 7 | print(
|
19 |
| - "comparing model_prices_and_context_window, and litellm/model_prices_and_context_window_backup.json files.......... checking they match", |
20 |
| - argv, |
| 8 | + "Comparing model_prices_and_context_window and litellm/model_prices_and_context_window_backup.json files... checking if they match." |
21 | 9 | )
|
22 | 10 |
|
23 | 11 | file1 = "model_prices_and_context_window.json"
|
24 | 12 | file2 = "litellm/model_prices_and_context_window_backup.json"
|
| 13 | + |
25 | 14 | cmp_result = filecmp.cmp(file1, file2, shallow=False)
|
| 15 | + |
26 | 16 | if cmp_result:
|
27 |
| - print(f"Passed ! Files {file1} and {file2} match.") |
| 17 | + print(f"Passed! Files {file1} and {file2} match.") |
28 | 18 | return 0
|
29 | 19 | else:
|
30 |
| - # show the diff |
31 |
| - print(f"Failed ! Files {file1} and {file2} do not match.") |
32 |
| - print("\nDiff") |
33 |
| - show_diff(file1, file2) |
34 |
| - |
| 20 | + print( |
| 21 | + f"Failed! Files {file1} and {file2} do not match. Copying content from {file1} to {file2}." |
| 22 | + ) |
| 23 | + copy_content(file1, file2) |
35 | 24 | return 1
|
36 | 25 |
|
37 | 26 |
|
| 27 | +def copy_content(source, destination): |
| 28 | + shutil.copy2(source, destination) |
| 29 | + |
| 30 | + |
38 | 31 | if __name__ == "__main__":
|
39 | 32 | sys.exit(main())
|
0 commit comments