aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2018-03-05 08:10:43 +0000
committerng0 <ng0@n0.is>2018-03-05 08:10:43 +0000
commit2046013659e9b495e8561a4cb56bc4e0de0287ac (patch)
tree922d5f9eaee2b5e1a825e9aafe88a651cef3c449 /contrib
parent66e6d0281c2247e9324be24a34802e09e79a6b0e (diff)
downloadgnunet-2046013659e9b495e8561a4cb56bc4e0de0287ac.tar.gz
gnunet-2046013659e9b495e8561a4cb56bc4e0de0287ac.zip
flake8 fixes for pydiffer
Diffstat (limited to 'contrib')
-rw-r--r--contrib/pydiffer.py.in67
1 files changed, 36 insertions, 31 deletions
diff --git a/contrib/pydiffer.py.in b/contrib/pydiffer.py.in
index 23d546b25..10145371c 100644
--- a/contrib/pydiffer.py.in
+++ b/contrib/pydiffer.py.in
@@ -4,36 +4,41 @@ import sys
4import difflib 4import difflib
5import filecmp 5import filecmp
6 6
7def getdiff (old, new): 7
8 diff = [] 8def getdiff(old, new):
9 with open (old) as a: 9 diff = []
10 with open (new) as b: 10 with open(old) as a:
11 for l in difflib.unified_diff (a.read ().splitlines (), b.read ().splitlines ()): 11 with open(new) as b:
12 diff.append (l) 12 for l in difflib.unified_diff(a.read().splitlines(), b.read().splitlines()):
13 return diff 13 diff.append(l)
14 14 return diff
15def dc_getdiff (dc, old, new): 15
16 diff = [] 16
17 for f in dc.left_only: 17def dc_getdiff(dc, old, new):
18 diff.append ("Only in {}: {}".format (old, f)) 18 diff = []
19 for f in dc.right_only: 19 for f in dc.left_only:
20 diff.append ("Only in {}: {}".format (new, f)) 20 diff.append("Only in {}: {}".format(old, f))
21 for f in dc.diff_files: 21 for f in dc.right_only:
22 r = getdiff (os.path.join (old, f), os.path.join (new, f)) 22 diff.append("Only in {}: {}".format(new, f))
23 diff.extend (r) 23 for f in dc.diff_files:
24 for dn, dc in dc.subdirs.items (): 24 r = getdiff(os.path.join(old, f), os.path.join(new, f))
25 r = dc_getdiff (dc, os.path.join (old, dn), os.path.join (new, dn)) 25 diff.extend(r)
26 diff.extend (r) 26 for dn, dc in dc.subdirs.items():
27 return diff 27 r = dc_getdiff(dc, os.path.join(old, dn), os.path.join(new, dn))
28 28 diff.extend(r)
29def dcdiff (old, new): 29 return diff
30 dc = filecmp.dircmp (old, new) 30
31 diff = dc_getdiff (dc, old, new) 31
32 return diff 32def dcdiff(old, new):
33 33 dc = filecmp.dircmp(old, new)
34def main (): 34 diff = dc_getdiff(dc, old, new)
35 for l in dcdiff (sys.argv[1], sys.argv[2]): 35 return diff
36 print (l) 36
37
38def main():
39 for l in dcdiff(sys.argv[1], sys.argv[2]):
40 print(l)
41
37 42
38if __name__ == '__main__': 43if __name__ == '__main__':
39 main () 44 main()