GNUnet  0.11.x
pydiffer.py
Go to the documentation of this file.
1 #!/home/buildbot/bb-worker/sandbox/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(
14  a.read().splitlines(),
15  b.read().splitlines()
16  ):
17  diff.append(l)
18  return diff
19 
20 
21 def dc_getdiff(dc, old, new):
22  diff = []
23  for f in dc.left_only:
24  diff.append("Only in {}: {}".format(old, f))
25  for f in dc.right_only:
26  diff.append("Only in {}: {}".format(new, f))
27  for f in dc.diff_files:
28  r = getdiff(os.path.join(old, f), os.path.join(new, f))
29  diff.extend(r)
30  for dn, dc in list(dc.subdirs.items()):
31  r = dc_getdiff(dc, os.path.join(old, dn), os.path.join(new, dn))
32  diff.extend(r)
33  return diff
34 
35 
36 def dcdiff(old, new):
37  dc = filecmp.dircmp(old, new)
38  diff = dc_getdiff(dc, old, new)
39  return diff
40 
41 
42 def main():
43  for l in dcdiff(sys.argv[1], sys.argv[2]):
44  print(l)
45 
46 
47 if __name__ == '__main__':
48  main()
def dcdiff(old, new)
Definition: pydiffer.py:36
def dc_getdiff(dc, old, new)
Definition: pydiffer.py:21
def main()
Definition: pydiffer.py:42
static int list
Set if we should print a list of currently running services.
Definition: gnunet-arm.c:69
def getdiff(old, new)
Definition: pydiffer.py:9