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$'
15 __short_args
= "a:c:ho:"
18 "columns=", "help", "output=",
21 "address=", "iconserver=",
22 "title=", "uplink=", "uptitle="]
28 uptitle
= "Python Documentation Index"
32 self
.variables
= {"address": "",
33 "iconserver": "icons",
35 "title": "Global Module Index",
38 def add_args(self
, short
=None, long=None):
40 self
.__short
_args
+= short
42 self
.__long
_args
+= long
44 def parse(self
, args
):
46 opts
, args
= getopt
.getopt(args
, self
.__short
_args
,
49 sys
.stdout
= sys
.stderr
54 if opt
in ("-a", "--address"):
57 val
= "<address>\n%s\n</address>\n" % val
58 self
.variables
["address"] = val
59 elif opt
in ("-h", "--help"):
62 elif opt
in ("-o", "--output"):
64 elif opt
in ("-c", "--columns"):
65 self
.columns
= int(val
)
66 elif opt
== "--title":
67 self
.variables
["title"] = val
.strip()
68 elif opt
== "--uplink":
69 self
.uplink
= val
.strip()
70 elif opt
== "--uptitle":
71 self
.uptitle
= val
.strip()
72 elif opt
== "--iconserver":
73 self
.variables
["iconserver"] = val
.strip() or "."
75 self
.handle_option(opt
, val
)
76 if self
.uplink
and self
.uptitle
:
77 self
.variables
["uplinkalt"] = "up"
78 self
.variables
["uplinkicon"] = "up"
80 self
.variables
["uplinkalt"] = ""
81 self
.variables
["uplinkicon"] = "blank"
82 self
.variables
["uplink"] = self
.uplink
83 self
.variables
["uptitle"] = self
.uptitle
85 def handle_option(self
, opt
, val
):
86 raise getopt
.error("option %s not recognized" % opt
)
89 return HEAD
% self
.variables
92 return TAIL
% self
.variables
94 def get_output_file(self
, filename
=None):
96 filename
= self
.outputfile
100 return open(filename
, "w")
104 <div class="navigation">
105 <table width="100%%" cellpadding="0" cellspacing="2">
107 <td><img width="32" height="32" align="bottom" border="0" alt=""
108 src="%(iconserver)s/blank.%(imgtype)s"></td>
109 <td><a href="%(uplink)s"
110 title="%(uptitle)s"><img width="32" height="32" align="bottom" border="0"
112 src="%(iconserver)s/%(uplinkicon)s.%(imgtype)s"></a></td>
113 <td><img width="32" height="32" align="bottom" border="0" alt=""
114 src="%(iconserver)s/blank.%(imgtype)s"></td>
115 <td align="center" width="100%%">%(title)s</td>
116 <td><img width="32" height="32" align="bottom" border="0" alt=""
117 src="%(iconserver)s/blank.%(imgtype)s"></td>
118 <td><img width="32" height="32" align="bottom" border="0" alt=""
119 src="%(iconserver)s/blank.%(imgtype)s"></td>
120 <td><img width="32" height="32" align="bottom" border="0" alt=""
121 src="%(iconserver)s/blank.%(imgtype)s"></td>
123 <b class="navlabel">Up:</b> <span class="sectref"><a href="%(uplink)s"
124 title="%(uptitle)s">%(uptitle)s</A></span>
129 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
132 <title>%(title)s</title>
133 <meta name="description" content="%(title)s">
134 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
135 <link rel="STYLESHEET" href="lib/lib.css">
138 ''' + NAVIGATION
+ '''\
145 TAIL
= "<hr>\n" + NAVIGATION
+ '''\