1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#!/usr/bin/env python3
#
# GNU Guix --- Functional package management for GNU
# Copyright © 2017,2019 Hartmut Goebel <h.goebel@crazy-compilers.com>
#
# License: GPLv3
import sys
import tempfile, bz2
import subprocess
def find_unknow_properties(filename):
if filename.endswith('.bz2'):
fh = bz2.open(filename, mode="rt")
else:
fh = open(filename, mode="rt")
store = []
for l in fh.readlines():
if l.startswith(("About to parse service type file ",
"Found property definition ",
"Unknown property type for ")):
store.append(l) #.rstrip())
elif l.startswith('Generated "'):
yield l.split('/build/', 1)[1].rstrip(), store
store = []
if store:
yield 'zzzzz', store
fh.close()
def strip_same_entries(me, there):
for k in list(me.keys()):
if k in there and me[k] == there[k]:
del me[k]
del there[k]
def make_diff(me, there):
def write_data(data):
fh = tempfile.NamedTemporaryFile('wt')
for k in sorted(list(data.keys())):
print(k, file=fh)
fh.writelines(data[k])
print(file=fh) # seperator
print(file=fh) # enforce newline end end of file
fh.flush()
return fh
me_fh = write_data(me)
there_fh = write_data(there)
import pdb ; pdb.set_trace()
#subprocess.call('hexdump %s | tail' % me_fh.name, shell=True)
#subprocess.call('hexdump %s | tail' % there_fh.name, shell=True)
subprocess.call(['emacs-diff', me_fh.name, there_fh.name])
me_fh.close()
there_fh.close()
me, there = sys.argv[1:3]
me = dict(find_unknow_properties(me))
there = dict(find_unknow_properties(there))
strip_same_entries(me, there)
make_diff(me, there)
|