GNUnet 0.21.1
pydiffer.py
Go to the documentation of this file.
1#!/home/buildbot/bb-worker/sandbox/bin/python
2
3import os
4import sys
5import difflib
6import filecmp
7
8
9def 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
21def 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
36def dcdiff(old, new):
37 dc = filecmp.dircmp(old, new)
38 diff = dc_getdiff(dc, old, new)
39 return diff
40
41
42def main():
43 for l in dcdiff(sys.argv[1], sys.argv[2]):
44 print(l)
45
46
47if __name__ == '__main__':
48 main()
static int list
Set if we should print a list of currently running services.
Definition: gnunet-arm.c:69
def dc_getdiff(dc, old, new)
Definition: pydiffer.py:21
def main()
Definition: pydiffer.py:42
def getdiff(old, new)
Definition: pydiffer.py:9
def dcdiff(old, new)
Definition: pydiffer.py:36