|
8 | 8 |
|
9 | 9 |
|
10 | 10 | def diff_and_remove(working, label_a, label_b, f): |
11 | | - a_deps = os.path.join(working, label_a, "tool_dependencies.xml") |
12 | | - b_deps = os.path.join(working, label_b, "tool_dependencies.xml") |
13 | | - a_repos = os.path.join(working, label_a, "repository_dependencies.xml") |
14 | | - b_repos = os.path.join(working, label_b, "repository_dependencies.xml") |
15 | | - |
| 11 | + assert label_a != label_b |
| 12 | + special = ["tool_dependencies.xml", "repository_dependencies.xml"] |
16 | 13 | deps_diff = 0 |
17 | | - if os.path.exists(a_deps) and os.path.exists(b_deps): |
18 | | - deps_diff = _shed_diff(a_deps, b_deps, f) |
19 | | - os.remove(a_deps) |
20 | | - os.remove(b_deps) |
21 | | - |
22 | | - repos_diff = 0 |
23 | | - if os.path.exists(a_repos) and os.path.exists(b_repos): |
24 | | - repos_diff = _shed_diff(a_repos, b_repos, f) |
25 | | - os.remove(a_repos) |
26 | | - os.remove(b_repos) |
27 | | - |
28 | | - return deps_diff and repos_diff |
| 14 | + # Could walk either A or B; will only compare if in same relative location |
| 15 | + for dirpath, dirnames, filenames in os.walk(os.path.join(working, label_a)): |
| 16 | + for filename in filenames: |
| 17 | + if filename in special: |
| 18 | + a = os.path.join(dirpath, filename) |
| 19 | + b = os.path.join(working, label_b, os.path.relpath(a, os.path.join(working, label_a))) |
| 20 | + if os.path.exists(a) and os.path.exists(b): |
| 21 | + deps_diff &= _shed_diff(a, b, f) |
| 22 | + os.remove(a) |
| 23 | + os.remove(b) |
| 24 | + return deps_diff |
29 | 25 |
|
30 | 26 |
|
31 | 27 | def _shed_diff(file_a, file_b, f=sys.stdout): |
|
0 commit comments