This repository has been archived by the owner on Jul 15, 2019. It is now read-only.
/
matrix.py
95 lines (82 loc) · 2 KB
/
matrix.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from django.template.response import TemplateResponse
from shogun.settings import MATRIX_FILE
def fetch_spreadsheet():
url='https://docs.google.com/spreadsheet/pub?hl=en&hl=en&key=0Aunb9cCVAP6NdDVBMzY1TjdPcmx4ei1EeUZNNGtKUHc&output=csv'
import urllib
f = urllib.urlopen(url)
csv = f.read()
file(MATRIX_FILE,'w').write(csv)
def get_matrix():
j=0
table=[]
for l in file(MATRIX_FILE).readlines():
j+=1
if j<19:
continue
#l=l.replace('&', '<td>')
if len(l)==1:
table.append("</td></tr></tbody><tbody><tr><td>\n")
if len(l)<=1:
continue
if l.find('shogun')>=0:
continue
s=l.split(',')
k=0
s2=list()
for i in s:
k+=1
if k<3:
i=i.replace(';', ', ')
s2.append(i)
continue
if '0/1' in i or '0.5' in i:
i='<img alt="partial" src="/static/design/partial.png">'
elif '0' in i:
i='<img alt="cross" src="/static/design/cross.png">'
elif '1' in i:
i='<img alt="tick" src="/static/design/tick.png">'
elif '?' in i:
i='<img alt="untested" src="/static/design/untested.png">'
s2.append(i)
c=0
for i in s2[:-1]:
c+=1
if c==1:
table.append('<strong>%s</strong></td><td width="300">' % i)
else:
table.append("%s</td><td>" % i)
table.append("%s</td></tr><tr><td>" % s2[-1])
return ''.join(table)
def get_related_projects():
tab=[]
j=0
LASTLINE=17
for l in file(MATRIX_FILE).readlines():
j+=1
if j>=LASTLINE+1:
break
if j<4:
continue
if len(l)==1:
tab.append("</td></tr><tr><td>\n")
if len(l)<=1:
continue
s=l.split(',')
s2=list()
for i in s[1:6]:
s2.append(i)
if l.find('created')>=0:
for i in s2[:-1]:
tab.append("%s</th><th>" % i)
tab.append("%s</th></tr></thead><tr><td>" % s2[-1])
else:
tab.append("<strong>%s</strong></td><td>" % s2[0])
for i in s2[1:-1]:
tab.append("%s</td><td>" % i)
if j==LASTLINE:
tab.append("%s</td></tr></table>" % s2[-1])
else:
tab.append("%s</td></tr><tr><td>" % s2[-1])
return ''.join(tab)
if __name__ == '__main__':
fetch_spreadsheet()