Mercurial > hg > python
annotate repair.py @ 65:5e5feacb730d
abandon regexp, work with lisparser output
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Thu, 14 Dec 2023 16:43:54 +0000 |
parents | fff2fa031ed7 |
children | 53c37a02d471 |
rev | line source |
---|---|
65
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
1 #!/usr/bin/python3 |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
2 import sys |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
3 |
60
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
4 import lisparser |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
5 |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
6 def readAlist(fn): |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
7 with open(fn,'r') as f: |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
8 sline = f.readline() |
65
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
9 alines = (l for l in f if (L:=l).startswith("(")) |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
10 return sline, alist(alines), L |
60
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
11 |
65
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
12 # alist fields are: group, rank, read, [marks, [method, [params]]] |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
13 # string int [list] [plist] expr plist |
60
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
14 def alist(lines): |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
15 res = {} |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
16 for l in lines: |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
17 ll = lisparser.get_ast(lisparser.normalize_str(l))[0] |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
18 k = ll.pop(0) |
65
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
19 n = int(ll.pop(0)) |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
20 res[eval(k)]=[n]+al2p(ll) |
60
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
21 return res |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
22 |
65
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
23 def al2p(ll): |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
24 '''handle read (list or nil), maybe marks (plist or nil), usually method, |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
25 maybe params (plist)''' |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
26 res=[ll.pop(0)] # read |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
27 if ll: |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
28 marks = ll.pop(0) |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
29 if marks != 'nil': |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
30 marks = dict((e[0],e[1:]) for e in marks) |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
31 res.append(marks) |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
32 else: |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
33 return res |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
34 if ll: |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
35 res.append(ll.pop(0)) # method |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
36 else: |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
37 return res |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
38 if ll: |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
39 res.append(dict((e[0],e[1:]) for e in ll.pop(0))) # params |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
40 else: |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
41 return res |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
42 if ll: |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
43 raise ValueError("too many args: %s"%ll) |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
44 return res |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
45 |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
46 def p2l(pl, f): |
60
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
47 if isinstance(pl,list) or isinstance(pl,tuple): |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
48 if len(pl) == 0: |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
49 f.write('nil') |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
50 else: |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
51 f.write('(') |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
52 space = False |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
53 for e in pl: |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
54 if space: |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
55 f.write(' ') |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
56 p2l(e,f) |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
57 else: |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
58 p2l(e,f) |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
59 space = True |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
60 f.write(')') |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
61 elif isinstance(pl,dict): |
65
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
62 f.write('(') |
60
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
63 space = False |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
64 for k, v in pl.items(): |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
65 if space: |
65
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
66 f.write(' (') |
60
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
67 else: |
65
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
68 f.write('(') |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
69 space = True |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
70 f.write(k) |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
71 for e in v: |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
72 f.write(' ') |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
73 p2l(e,f) |
60
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
74 f.write(')') |
65
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
75 f.write(')') |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
76 # elif isinstance(pl,str): |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
77 # if pl in ['.','nil']: |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
78 # f.write(pl) |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
79 # else: |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
80 # try: |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
81 # int(pl) |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
82 # f.write(pl) |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
83 # except ValueError: |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
84 # f.write(pl) |
60
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
85 else: |
bc1acb1416ab
working on fixing gnus home foulup, see /disk/scratch/{mail,gnus}
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
86 f.write(pl) |
62
c82a8743fd48
taking notes on how to merge
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
60
diff
changeset
|
87 |
65
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
88 def merge(gnus, mail, out): |
62
c82a8743fd48
taking notes on how to merge
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
60
diff
changeset
|
89 ''' |
c82a8743fd48
taking notes on how to merge
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
60
diff
changeset
|
90 rank, read, marks, method, params |
c82a8743fd48
taking notes on how to merge
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
60
diff
changeset
|
91 |
c82a8743fd48
taking notes on how to merge
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
60
diff
changeset
|
92 read is everything that is unmarked (nothing in left column) |
c82a8743fd48
taking notes on how to merge
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
60
diff
changeset
|
93 marks.seen is everything that has ever been looked it and not DELETED |
c82a8743fd48
taking notes on how to merge
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
60
diff
changeset
|
94 marks.tick is a !, marks.forward is F, marks.reply is A. |
c82a8743fd48
taking notes on how to merge
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
60
diff
changeset
|
95 |
c82a8743fd48
taking notes on how to merge
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
60
diff
changeset
|
96 rank: deeper in gnus wins |
c82a8743fd48
taking notes on how to merge
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
60
diff
changeset
|
97 read: if unequal |
c82a8743fd48
taking notes on how to merge
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
60
diff
changeset
|
98 if mail is nil, use gnus |
c82a8743fd48
taking notes on how to merge
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
60
diff
changeset
|
99 otherwise use mail |
c82a8743fd48
taking notes on how to merge
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
60
diff
changeset
|
100 marks: merge unseen keys, unequal values for same key prefer gnus |
65
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
101 EXCEPT bogus, w3c-ac-forum, handle by hand DONE |
62
c82a8743fd48
taking notes on how to merge
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
60
diff
changeset
|
102 method: change "ht" to "nnml+ht", flag anything else |
65
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
103 FIX group-2002-07 in gnus by hand DONE |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
104 params: merge by keys |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
105 ''' # ' |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
106 global g, m |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
107 g1, g, g2 = readAlist(gnus) |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
108 _, m, _ = readAlist(mail) |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
109 with open(out, "w") as outf: |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
110 outf.write(g1) |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
111 for k, v in g.items(): |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
112 if k in m: |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
113 return |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
114 res = mergeOne(v, m[k]) |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
115 else: |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
116 res = v |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
117 outf.write('("%s" '%k) |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
118 outf.write(str(res[0])) # rank |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
119 for v in res[1:]: |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
120 outf.write(' ') |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
121 p2l(v,outf) |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
122 outf.write(')\n') |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
123 outf.write(g2) |
62
c82a8743fd48
taking notes on how to merge
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
60
diff
changeset
|
124 |
65
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
125 def stale(): |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
126 ''' |
64 | 127 |
62
c82a8743fd48
taking notes on how to merge
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
60
diff
changeset
|
128 Comparison tool: |
c82a8743fd48
taking notes on how to merge
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
60
diff
changeset
|
129 |
c82a8743fd48
taking notes on how to merge
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
60
diff
changeset
|
130 Watch out for tabs! |
c82a8743fd48
taking notes on how to merge
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
60
diff
changeset
|
131 To look for overlap, change 2nd \n in printf to \t |
c82a8743fd48
taking notes on how to merge
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
60
diff
changeset
|
132 |
63 | 133 export T=$'\t' |
64 | 134 export B1="(\(\([^()]\+\|([^)]*)\) \?\)*)" |
135 export P1="\(nil\|$B1\)" | |
136 export P2="\(nil\|\((\($B1 \?\)*)\)\)" | |
137 export MA='\("[^"]*"\|(nndraft "")\)' | |
138 fgrep -hf shared {gnus,mail}/alist.fixed | sed 's/ \([0-9]\) '"$P1 $P2 / \1 \2 \5 /;s/\(.*${T}.*${T}.*${T}\)$MA $P2/\1\2${T}\4/" | |
139 paste <(cat shared) <(fgrep -f shared mail/alist.fixed | sed 's/ \([0-9]\) '"$P $P/ \1 \2 \5 /g" | cut -f 3) <(fgrep -f shared gnus/alist.fixed | sed 's/ \([0-9]\) '"$P $P/ \1 \2 \5 /g" | cut -f 3) | { IFS=' ' ; while read gn g m; do if [ "$g" != "$m" ]; then printf "=----%s------\n%s\n%s\n" "$gn" "$g" "$m"; fi; done ; } | less | |
62
c82a8743fd48
taking notes on how to merge
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
60
diff
changeset
|
140 ''' |
65
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
141 |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
142 if __name__ == '__main__': |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
143 merge(*sys.argv[1:]) |
5e5feacb730d
abandon regexp, work with lisparser output
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
64
diff
changeset
|
144 |