-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPyQwtGenerator.py
187 lines (149 loc) · 7.04 KB
/
PyQwtGenerator.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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
"""Generates the www.python.org website style
"""
import os
import posixpath
import time
from Skeleton import Skeleton
from Sidebar import Sidebar, BLANKCELL
from Banner import Banner
from HTParser import HTParser
from LinkFixer import LinkFixer
sitelinks = [
('%(rootdir)s/home.html', 'Home'),
('%(rootdir)s/cli-examples.html', 'PyQwt CLI Examples'),
('%(rootdir)s/gui-examples.html', 'PyQwt GUI Examples'),
('%(rootdir)s/download.html', 'PyQwt Download'),
('%(rootdir)s/faq.html', 'FAQ'),
('%(rootdir)s/license.html', 'License'),
('%(rootdir)s/pyqwt3d-examples.html', 'PyQwt3D Examples'),
('%(rootdir)s/feedback.html', 'Happy Users'),
]
import nospam
class NoSpamHTParser(HTParser):
def __init__(self, filename, default_author=None, default_email=None):
HTParser.__init__(self, filename, default_author, default_email)
def process_sidebar(self):
HTParser.process_sidebar(self)
author = self.get('author') # guaranteed
email = self.get('author-email', author)
self.sidebar[-1] = (nospam.hide('mailto:' + email),
nospam.hide(author))
# class NoSpamHTParser
class PyQwtGenerator(Skeleton, Sidebar, Banner):
def __init__(self, file, rootdir, relthis):
root, ext = os.path.splitext(file)
html = root + '.html'
p = self.__parser = NoSpamHTParser(file, '[email protected]')
f = self.__linkfixer = LinkFixer(html, rootdir, relthis)
self.__body = None
self.__cont = None
# calculate the sidebar links, adding a few of our own
self.__d = {'rootdir': rootdir}
p.process_sidebar()
# copyrigth
copyright = self.__parser.get('copyright',
'2001-%d' % time.localtime()[0])
p.sidebar.append(BLANKCELL)
p.sidebar.append((None, '© ' + copyright))
p.sidebar.append((None, 'Gerard Vermeulen'))
copyright = self.__parser.get('copyright', '2000')
p.sidebar.append(BLANKCELL)
p.sidebar.append((None, '© ' + copyright))
p.sidebar.append((None, 'Mark Colclough'))
# it is important not to have newlines between the img tag and the end
# end center tags, otherwise layout gets messed up
# sourceforge link.
p.sidebar.append(BLANKCELL)
p.sidebar.append(('http://sourceforge.net', '<center><img src="http://sourceforge.net/sflogo.php?group_id=82987&type=2" width="125" height="37" border="0" alt="SourceForge Logo"></center>'))
# Python
p.sidebar.append(BLANKCELL)
p.sidebar.append(('http://www.python.org', '<center><img alt="Python Powered Logo" border="0" src="%(rootdir)s/images/PythonPowered.png"></center>' % self.__d))
# Sign the petition against European software patents
p.sidebar.append(BLANKCELL)
p.sidebar.append(('http://swpat.ffii.org/', '''
<center><img alt="The fight against software patents in Europe in not over" border="0" src="%(rootdir)s/images/no_epatents.png"></center>''' % self.__d))
# Why are software patents bad?
p.sidebar.append(BLANKCELL)
p.sidebar.append(('http://www.nosoftwarepatents.com//en/m/basics/index.html', '''
<center><img alt="Why are software patents bad?" border="0" src="%(rootdir)s/images/90x40_3.jpg"></center>''' % self.__d))
# donation
p.sidebar.append(BLANKCELL)
p.sidebar.append(('http://sourceforge.net/donate/index.php?group_id=82987', '<center><img src="http://images.sourceforge.net/images/project-support.jpg" width="88" height="32" border="0" alt="Support This Project"></center>'))
Sidebar.__init__(self, p.sidebar)
#
# fix up our site links, no relthis because the site links are
# relative to the root of our web pages
#
sitelink_fixer = LinkFixer(f.myurl(), rootdir)
sitelink_fixer.massage(sitelinks, self.__d, aboves=1)
Banner.__init__(self, sitelinks)
# __init__()
def get_stylesheet(self):
return posixpath.join(self.__d['rootdir'], 'style.css')
def get_title(self):
return self.__parser.get('title')
def get_sidebar(self):
return Sidebar.get_sidebar(self)
def get_banner(self):
return Banner.get_banner(self)
def get_banner_attributes(self):
return 'cellspacing="0" cellpadding="5"'
def get_corner(self):
# it is important not to have newlines between the img tag and the end
# anchor and end center tags, otherwise layout gets messed up
#return '<center><b><p>PyQwt</p><p>PyQwt3D</p></b></center>'
return (
'<center>'
'<a href="http://sourceforge.net/donate/index.php?group_id=82987">'
'<img src="http://images.sourceforge.net/images/project-support.jpg"'
' width="88" height="32" border="0" alt="Support This Project">'
'</center>')
def get_corner_bgcolor(self):
return '#3399ff'
def get_body(self):
self.__grokbody()
return self.__body
def get_cont(self):
self.__grokbody()
return self.__cont
def __grokbody(self):
if self.__body is None:
text = self.__parser.fp.read()
text += (
'\n<p>'
'\n<table bgcolor="#99CCFF" width="100%">'
'\n<tr>'
'\n<td>'
'\n<h3>Help to stop software patents</h3>'
'\n<p>Free software and small and/or medium sized software '
'companies are threatened by patents on '
'<a href="http://swpat.ffii.org/patents/samples/index.en.html">algorithms</a> and '
'<a href="http://webshop.ffii.org">business methods</a>.</p>'
'\n<ol>'
'\n<li>Read this <a href="http://www.nosoftwarepatents.com/en/m/basics/index.html">excellent explanation</a> of the devastating effects of software patents on software (users!) and software development (developers!)</li>'
'\n<li>Read <a href="http://swpat.ffii.org"> how the European Commission and the patent lobby</a> are still trying to introduce software patents</li>'
'\n<li>Support the <a href="http://www.eff.org/patent/">Patent Busting Project</a> of the Electronic Frontier Foundation in the USA</li>'
'\n</ol>'
'\n</td>'
'\n</tr>'
'\n</table>'
'\n</p>'
)
text = nospam.filter(text)
i = text.find('<!--table-stop-->')
if i >= 0:
self.__body = text[:i]
self.__cont = text[i+17:]
else:
# there is no wide body
self.__body = text
# python.org color scheme overrides
def get_lightshade(self):
return '#99ccff'
def get_mediumshade(self):
return '#3399ff'
def get_darkshade(self):
return '#003366'
def get_charset(self):
return 'iso-8859-1'
# class PyQwtGenerator