Mercurial > hg > python
changeset 66:53c37a02d471
working, I think/hope
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Thu, 14 Dec 2023 20:17:48 +0000 |
parents | 5e5feacb730d |
children | eb4be545fcc8 |
files | repair.py |
diffstat | 1 files changed, 52 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/repair.py Thu Dec 14 16:43:54 2023 +0000 +++ b/repair.py Thu Dec 14 20:17:48 2023 +0000 @@ -36,7 +36,11 @@ else: return res if ll: - res.append(dict((e[0],e[1:]) for e in ll.pop(0))) # params + params = ll.pop(0) + if params == 'nil': + res.append(params) + else: + res.append(dict((e[0],e[1:]) for e in params)) # params else: return res if ll: @@ -85,6 +89,49 @@ else: f.write(pl) +def mergeOne(gv,mv): + '''rank: deeper in gnus wins + read: if unequal + if mail is nil, use gnus + otherwise use mail + marks: merge unseen keys, unequal values for same key prefer gnus + EXCEPT bogus, w3c-ac-forum, handle by hand DONE + method: change "ht" to "nnml+ht" + FIX group-2002-07 in gnus by hand DONE + params: merge by keys +''' + res = mv.copy() + if gv[0] > res[0]: # rank + res[0] = gv[0] + if res[1] == 'nil': # read + res[1] = gv[1] + if res[2] != gv[2]: # marks + if res[2] == 'nil': + res[2] = gv[2] + else: + for k, v in gv[2].items(): + # fill in missing, override unequal, if equal no harm done + res[2][k] = v + # we prefer m to g for method + if len(res) == 4: + # no params + if len(gv) == 5: + res.append(gv[4]) + elif len(gv) == 5: + if res[4] != gv[4]: + for k, v in gv[4].items(): + # fill in missing, override unequal, if equal no harm done + res[4][k] = v + return res + +def lineout(k,res,outf): + outf.write('("%s" '%k) + outf.write(str(res[0])) # rank + for v in res[1:]: + outf.write(' ') + p2l(v,outf) + outf.write(')\n') + def merge(gnus, mail, out): ''' rank, read, marks, method, params @@ -92,16 +139,6 @@ read is everything that is unmarked (nothing in left column) marks.seen is everything that has ever been looked it and not DELETED marks.tick is a !, marks.forward is F, marks.reply is A. - - rank: deeper in gnus wins - read: if unequal - if mail is nil, use gnus - otherwise use mail - marks: merge unseen keys, unequal values for same key prefer gnus - EXCEPT bogus, w3c-ac-forum, handle by hand DONE - method: change "ht" to "nnml+ht", flag anything else - FIX group-2002-07 in gnus by hand DONE - params: merge by keys ''' # ' global g, m g1, g, g2 = readAlist(gnus) @@ -110,16 +147,13 @@ outf.write(g1) for k, v in g.items(): if k in m: - return res = mergeOne(v, m[k]) else: res = v - outf.write('("%s" '%k) - outf.write(str(res[0])) # rank - for v in res[1:]: - outf.write(' ') - p2l(v,outf) - outf.write(')\n') + lineout(k,res,outf) + for k, v in m.items(): + if k not in g: + lineout(k,v,outf) outf.write(g2) def stale():