GNUnet  0.10.x
pydiffer.py
Go to the documentation of this file.
1 #!/usr/bin/python3
2 
3 import os
4 import sys
5 import difflib
6 import filecmp
7 
8 
9 def getdiff(old, new):
10  diff = []
11  with open(old) as a:
12  with open(new) as b:
13  for l in difflib.unified_diff(a.read().splitlines(), b.read().splitlines()):
14  diff.append(l)
15  return diff
16 
17 
18 def dc_getdiff(dc, old, new):
19  diff = []
20  for f in dc.left_only:
21  diff.append("Only in {}: {}".format(old, f))
22  for f in dc.right_only:
23  diff.append("Only in {}: {}".format(new, f))
24  for f in dc.diff_files:
25  r = getdiff(os.path.join(old, f), os.path.join(new, f))
26  diff.extend(r)
27  for dn, dc in list(dc.subdirs.items()):
28  r = dc_getdiff(dc, os.path.join(old, dn), os.path.join(new, dn))
29  diff.extend(r)
30  return diff
31 
32 
33 def dcdiff(old, new):
34  dc = filecmp.dircmp(old, new)
35  diff = dc_getdiff(dc, old, new)
36  return diff
37 
38 
39 def main():
40  for l in dcdiff(sys.argv[1], sys.argv[2]):
41  print(l)
42 
43 
44 if __name__ == '__main__':
45  main()
def dcdiff(old, new)
Definition: pydiffer.py:33
def dc_getdiff(dc, old, new)
Definition: pydiffer.py:18
def main()
Definition: pydiffer.py:39
static int list
Set if we should print a list of currently running services.
Definition: gnunet-arm.c:64
def getdiff(old, new)
Definition: pydiffer.py:9