Skip to content

Commit d133b88

Browse files
committed
cleanup & docs
1 parent 4a0b672 commit d133b88

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

webdiff/diff.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
'''Utility code for working with Diff objects.'''
1+
'''Utility code for working with Diff objects.
2+
3+
Diff objects must have these properties:
4+
- a Name of the file on the left side of a diff
5+
- a_path Path to a copy of the left side file on local disk.
6+
- b (like a)
7+
- b_path (like a_path)
8+
- type One of {'change', 'move', 'add', 'delete'}
9+
10+
For concrete implementations, see githubdiff and localfilediff.
11+
'''
212

313
import mimetypes
414

@@ -84,10 +94,11 @@ def find_diff_index(diffs, side, path):
8494
Returns None if there's no diff for the (side, path) pair.
8595
'''
8696
assert side in ('a', 'b')
87-
# TODO: os.path.normpath
97+
norm = os.path.normpath
98+
path = norm(path)
8899
for idx, diff in enumerate(diffs):
89-
if side == 'a' and diff.a == path:
100+
if side == 'a' and norm(diff.a) == path:
90101
return idx
91-
if side == 'b' and diff.b == path:
102+
if side == 'b' and norm(diff.b) == path:
92103
return idx
93104
return None

0 commit comments

Comments
 (0)