added initial version of dvi to ps converter based on PyX
[PyX/mjg.git] / www / pt2html.py
blobbecdc358fb05d25640b3b4844955cf5ab928934f
1 #!/usr/bin/env python
2 # -*- coding: ISO-8859-1 -*-
4 import sys, os.path, codecs, encodings
5 from zope.pagetemplate.pagetemplate import PageTemplate
7 class example:
8 def __init__(self, name):
9 self.name = name
10 self.png = "examples/%s.png" % self.name
11 self.eps = "examples/%s.eps" % self.name
12 self.code = open("../examples/%s.py.html" % name, "r").read()
13 self.code = self.code.replace("ä", "ä")
14 self.code = self.code.replace("Ä", "Ä")
15 self.code = self.code.replace("ö", "ö")
16 self.code = self.code.replace("Ö", "Ö")
17 self.code = self.code.replace("ü", "ü")
18 self.code = self.code.replace("Ü", "Ü")
19 self.code = self.code.replace("ß", "ß")
20 self.code = self.code.replace("é", "é")
21 def __getattr__(self, attr):
22 return self.__dict__[attr]
24 def PageTemplateFromFile(filename):
25 pt = PageTemplate()
26 pt.write(open(filename, "r").read())
27 return pt
29 def write_file(filename, string):
30 # path = os.path.join(os.path.expanduser(outpath), filename)
31 # print "Writing %s ..." % path
32 open(filename, "w").write(string)
34 maintemplate = PageTemplateFromFile("maintemplate.pt")
36 pagename = sys.argv[1]
37 if pagename.endswith(".pt"): pagename = pagename[:-3]
39 examples = [example("hello"),
40 example("latex"),
41 example("pattern"),
42 example("circles"),
43 example("vector"),
44 example("box"),
45 example("connect"),
46 example("valign"),
47 example("tree"),
48 example("sierpinski"),
49 example("graphs/minimal"),
50 example("graphs/lissajous"),
51 example("graphs/piaxis"),
52 example("graphs/manyaxes"),
53 example("graphs/inset"),
54 example("graphs/link"),
55 example("graphs/change"),
56 example("graphs/bar"),
57 example("graphs/arrows"),
58 example("graphs/mandel"),
59 example("graphs/integral"),
60 example("graphs/partialfill"),
61 example("graphs/washboard"),
62 example("axis/simple"),
63 example("axis/painter"),
64 example("axis/rating"),
65 example("axis/manualticks"),
66 example("axis/parter"),
67 example("axis/texter"),
68 example("axis/log")]
70 write_file("%s.html" % pagename,
71 PageTemplateFromFile("%s.pt" % pagename)(maintemplate=maintemplate,
72 pagename="%s.html" % pagename,
73 examples=examples))