Menu

[r164]: / trunk / htdocs / convert.py  Maximize  Restore  History

Download this file

161 lines (135 with data), 4.8 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import yaptu
import re, os, sys, copy
from StringIO import StringIO
rex=re.compile('@([^@]+)@')
rbe=re.compile('\s*\+')
ren=re.compile('\s*-')
rco=re.compile('\s*= ')
class LinkBox:
def __init__(self, header, links):
self.header = header
self.links = links
def format_header(self):
return """
<tr><td bgcolor=#bfbfbf align="left">
<font class="tableheading">
<b>%s</b>
</font>
</td></tr>
""" % self.header
def __repr__(self):
s = '<table width=100% border=1 cellpadding=1 ' +\
'cellspacing=1>\n'
s += self.format_header()
s += ' <tr><td valign="top" bgcolor=#efefef>\n'
for text, link in self.links:
s += ' <a href=%s>%s</a><br>\n' % (link, text)
s += '</td></tr>\n'
s += '</table>\n'
return s
table1 = LinkBox(header='Matplotlib', links=(
('Home', 'http://matplotlib.sourceforge.net'),
('Download', 'http://sourceforge.net/projects/matplotlib'),
('Installing', 'installing.html'),
('Screenshots', 'screenshots.html'),
("What's&nbsp;New", 'whats_new.html'),
('Mailing lists', 'http://sourceforge.net/mail/?group_id=80706'),
))
table2 = LinkBox(header='Documentation', links=(
('Tutorial', 'tutorial.html'),
('FAQ', 'faq.html'),
('Matlab&nbsp;interface', 'matlab_commands.html'),
('Class&nbsp;library', 'classdocs.html'),
('Backends', 'backends.html'),
('Fonts', 'fonts.html'),
('Interactive', 'interactive.html'),
('Goals', 'goals.html'),
))
table3 = LinkBox(header='Other', links=(
('Credits', 'credits.html'),
('License', 'license.html'),
))
params = {
'myemail' : '<a href=mailto:jdhunter@ace.bsd.uchicago.edu> (jdhunter@ace.bsd.uchicago.edu)</a>',
'tables' : (table1, table2, table3),
'default_table' : 'border=1 cellpadding=3 cellspacing=2',
}
headerBuffer = StringIO()
cop = yaptu.copier(rex, params, rbe, ren, rco, ouf=headerBuffer)
lines = file('header.html.template').readlines()
cop.copy(lines)
params['header'] = headerBuffer.getvalue()
footerBuffer = StringIO()
cop = yaptu.copier(rex, params, rbe, ren, rco, ouf=footerBuffer)
lines = file('footer.html.template').readlines()
cop.copy(lines)
params['footer'] = footerBuffer.getvalue()
docs = (
'matplotlib.afm.html.template',
'matplotlib.artist.html.template',
'matplotlib.axes.html.template',
'matplotlib.axis.html.template',
'matplotlib.backend_bases.html.template',
'matplotlib.backends.backend_agg.html.template',
'matplotlib.backends.backend_gd.html.template',
'matplotlib.backends.backend_gtk.html.template',
'matplotlib.backends.backend_gtkgd.html.template',
'matplotlib.backends.backend_paint.html.template',
'matplotlib.backends.backend_ps.html.template',
'matplotlib.backends.backend_template.html.template',
'matplotlib.backends.backend_tkagg.html.template',
'matplotlib.backends.backend_wx.html.template',
'matplotlib.colors.html.template',
'matplotlib.cbook.html.template',
'matplotlib.figure.html.template',
'matplotlib.legend.html.template',
'matplotlib.lines.html.template',
'matplotlib.matlab.html.template',
'matplotlib.mathtext.html.template',
'matplotlib.mlab.html.template',
'matplotlib.numerix.html.template',
'matplotlib.patches.html.template',
'matplotlib.table.html.template',
'matplotlib.text.html.template',
'matplotlib.transforms.html.template',
)
files = [
'backends.html.template',
'classdocs.html.template',
'credits.html.template',
'faq.html.template',
'fonts.html.template',
'goals.html.template',
'index.html.template',
'installing.html.template',
'interactive.html.template',
'license.html.template',
'matlab_commands.html.template',
'screenshots.html.template',
'tutorial.html.template',
'whats_new.html.template',
]
files.extend(docs)
#print params
keysOrig = {}
for key in locals().keys():
keysOrig[key] = 1
for inFile in files:
print '\tConverting', inFile
fh = file(inFile, 'r')
s = ''
while 1:
line = fh.readline()
if line.find('@header@')==0:
break
s += line
fileParams = copy.copy(params)
if len(s)>0: exec(s)
for key, val in locals().items():
if not keysOrig.has_key(key):
fileParams[key] = val
outFile, ext = os.path.splitext(inFile)
cop = yaptu.copier(rex, fileParams, rbe, ren, rco, ouf=file(outFile, 'w'))
lines = ['@header@']
lines.extend(fh.readlines())
cop.copy(lines)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.