-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversioncsv2doctable.py
More file actions
executable file
·113 lines (77 loc) · 2.61 KB
/
Copy pathversioncsv2doctable.py
File metadata and controls
executable file
·113 lines (77 loc) · 2.61 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/python
import sys
import pprint
indent=2
t_in='<table style="border-collapse: collapse; border: solid 1px black;">'
t_out='</table>'
th_in='<th style="border: 1px solid black; text-align:center;">'
th_out='</th>'
td_in='<td style="border: 1px solid black; text-align:center;">'
td_out='</td>'
pp = pprint.PrettyPrinter()
in_header = sys.stdin.readline().rstrip()
in_header = in_header.split(',')
(PkgBundleFriendlyname,PkgDlURLRoot)=in_header[1].split(';')
PkgList=[]
for item in in_header[2:]:
item.rstrip()
(name,repo)=item.split(';')
PkgList.append({'PkgName':name, 'PkgRepoURL':repo})
PkgTable={}
in_data = sys.stdin.readline().rstrip()
while in_data:
if in_data == '': break
in_data=in_data.split(',')
#print "New dataline ---"
#print in_data
branch=in_data[0]
if not (branch in PkgTable.keys()):
PkgTable[branch]=[]
#print PkgTable
Packages=[]
for item in in_data[2:]:
item.rstrip()
item+=";0"
(version,hash)=item.split(';')[:2]
Packages.append({'PackageVersion':version, 'PackageHash':hash})
PkgTable[branch].append({'BundleVersion':in_data[1], 'Packages':Packages})
#print PkgTable
in_data = sys.stdin.readline().rstrip()
#print PkgBundleFriendlyname
#print PkgDlURLRoot
#pp.pprint(PkgList)
#pp.pprint(PkgTable)
for branch in PkgTable.keys():
title = branch + " branch version table"
print
print
print title.capitalize()
print '*'*len(title)
print
print '.. raw:: html'
print
print ' '*indent*1 + t_in
print ' '*indent*2 + '<thead>'
print ' '*indent*3 + '<tr>'
print ' '*indent*4 + th_in + PkgBundleFriendlyname + th_out
for item in PkgList:
print ' '*indent*4 + th_in + '<a href="' + item['PkgRepoURL'] + '">' + item['PkgName'] +'</a>' + th_out
print ' '*indent*3 + '</tr>'
print ' '*indent*2 + '</thead>'
branch_items = sorted(PkgTable[branch], key=lambda item: map(int, item["BundleVersion"].split(".")), reverse=True)
for line in branch_items:
#print line
pkgline=line['Packages']
print ' '*indent*3 + '<tr>'
print ' '*indent*4 + td_in + '<a href="' + PkgDlURLRoot + '/' + branch + '/' + line['BundleVersion'] + '">' + line['BundleVersion'] + '</a>' + td_out
for i in range(0,len(pkgline)):
item=pkgline[i]
header=PkgList[i]
#print item
#print header
if ( item['PackageVersion'] == 'N/A') :
print ' '*indent*4 + td_in + 'N/A' + td_out
else:
print ' '*indent*4 + td_in + '<a href="' + header['PkgRepoURL'] + '/tree/' + item['PackageHash'] + '">' + item['PackageVersion'] + '</a>' + td_out
print ' '*indent*3 + '</tr>'
print ' '*indent*1 + t_out