1
"""Miscellaneous support code shared by some of the tool scripts.
3
This includes option parsing code, HTML formatting code, and a couple of
7
__version__ = '$Revision: 1.1.1.1 $'
16
__short_args = "a:c:ho:"
19
"columns=", "help", "output=",
22
"address=", "iconserver=",
23
"title=", "uplink=", "uptitle="]
29
uptitle = "Python Documentation Index"
33
self.variables = {"address": "",
34
"iconserver": "icons",
36
"title": "Global Module Index",
39
def add_args(self, short=None, long=None):
41
self.__short_args = self.__short_args + short
43
self.__long_args = self.__long_args + long
45
def parse(self, args):
47
opts, args = getopt.getopt(args, self.__short_args,
50
sys.stdout = sys.stderr
53
self.args = self.args + args
55
if opt in ("-a", "--address"):
56
val = string.strip(val)
58
val = "<address>\n%s\n</address>\n" % val
59
self.variables["address"] = val
60
elif opt in ("-h", "--help"):
63
elif opt in ("-o", "--output"):
65
elif opt in ("-c", "--columns"):
66
self.columns = int(val)
67
elif opt == "--title":
68
self.variables["title"] = val.strip()
69
elif opt == "--uplink":
70
self.uplink = val.strip()
71
elif opt == "--uptitle":
72
self.uptitle = val.strip()
73
elif opt == "--iconserver":
74
self.variables["iconserver"] = val.strip() or "."
76
self.handle_option(opt, val)
77
if self.uplink and self.uptitle:
78
self.variables["uplinkalt"] = "up"
79
self.variables["uplinkicon"] = "up"
81
self.variables["uplinkalt"] = ""
82
self.variables["uplinkicon"] = "blank"
83
self.variables["uplink"] = self.uplink
84
self.variables["uptitle"] = self.uptitle
86
def handle_option(self, opt, val):
87
raise getopt.error("option %s not recognized" % opt)
90
return HEAD % self.variables
93
return TAIL % self.variables
95
def get_output_file(self, filename=None):
97
filename = self.outputfile
101
return open(filename, "w")
105
<div class="navigation">
106
<table width="100%%" cellpadding="0" cellspacing="2">
108
<td><img width="32" height="32" align="bottom" border="0" alt=""
109
src="%(iconserver)s/blank.%(imgtype)s"></td>
110
<td><a href="%(uplink)s"
111
title="%(uptitle)s"><img width="32" height="32" align="bottom" border="0"
113
src="%(iconserver)s/%(uplinkicon)s.%(imgtype)s"></a></td>
114
<td><img width="32" height="32" align="bottom" border="0" alt=""
115
src="%(iconserver)s/blank.%(imgtype)s"></td>
116
<td align="center" width="100%%">%(title)s</td>
117
<td><img width="32" height="32" align="bottom" border="0" alt=""
118
src="%(iconserver)s/blank.%(imgtype)s"></td>
119
<td><img width="32" height="32" align="bottom" border="0" alt=""
120
src="%(iconserver)s/blank.%(imgtype)s"></td>
121
<td><img width="32" height="32" align="bottom" border="0" alt=""
122
src="%(iconserver)s/blank.%(imgtype)s"></td>
124
<b class="navlabel">Up:</b> <span class="sectref"><a href="%(uplink)s"
125
title="%(uptitle)s">%(uptitle)s</A></span>
130
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
133
<title>%(title)s</title>
134
<meta name="description" content="%(title)s">
135
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
136
<link rel="STYLESHEET" href="lib/lib.css">
139
''' + NAVIGATION + '''\
146
TAIL = "<hr>\n" + NAVIGATION + '''\