-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwt_progress.py
executable file
·78 lines (62 loc) · 2.48 KB
/
wt_progress.py
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python
import gedcom
import sys
if len(sys.argv) != 3:
print 'usage: wt_progress.py in.ged name'
exit(1)
g = gedcom.Gedcom(sys.argv[1])
llg = gedcom.LineageLinkedGedcom(g)
root = None
root_name = sys.argv[2]
for i in llg.individuals:
if i.isName(root_name):
root = i
break
if root is None:
print 'individual not found:',root_name
exit(1)
generations = [[root]]
cur_gen = 0
www_missing = []
print '<html><body>'
while cur_gen < len(generations):
for i in generations[cur_gen]:
f = i.getValue('FAMC')
if f is None:
print cur_gen,
if i.get('WWW') is not None:
print '<a href="'+i.get('WWW').value+'">'+i.get('WWW').value+'</a>',
print '\t'+str(i.get('NAME')),'missing parents<br>'
else:
if len(generations) <= cur_gen+1:
generations.append([])
if f.getValue('HUSB') is None:
print cur_gen,
if i.get('WWW') is not None:
print '<a href="'+i.get('WWW').value+'">'+i.get('WWW').value+'</a>',
print '\t',i.get('NAME'),'missing father<br>'
else:
generations[cur_gen+1].append(f.getValue('HUSB'))
if f.getValue('HUSB').get('WWW') is None and (i ,f) not in www_missing:
www_missing.append((i,f))
if f.getValue('WIFE') is None:
print cur_gen,
if i.get('WWW') is not None:
print '<a href="'+i.get('WWW').value+'">'+i.get('WWW').value+'</a>',
print '\t',i.get('NAME'),'missing mother<br>'
else:
generations[cur_gen+1].append(f.getValue('WIFE'))
if f.getValue('WIFE').get('WWW') is None and (i,f) not in www_missing:
www_missing.append((i,f))
cur_gen += 1
for i,f in www_missing:
print 'WWW\t',
if i.get('WWW') is not None:
print '<a href="'+i.get('WWW').value+'">'+i.get('WWW').value+'</a>',
if f.getValue('HUSB') is not None and f.getValue('HUSB').get('WWW') is None:
print '\t',i.get('NAME'),'father is missing WWW link<br>'
if f.getValue('WIFE') is not None and f.getValue('WIFE').get('WWW') is None:
print '\t',i.get('NAME'),'mother is missing WWW link<br>'
for i in range (len(generations)):
print 'generation',i,'-',len(generations[i]),'of',2**i,'(',len(generations[i])*100/float(2**i),'%)<br>'
print '</body></html>'