summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util/optionlist/Makefile7
-rw-r--r--util/optionlist/Options.xsl54
-rw-r--r--util/optionlist/README24
-rwxr-xr-xutil/optionlist/mkOptionList.py123
4 files changed, 208 insertions, 0 deletions
diff --git a/util/optionlist/Makefile b/util/optionlist/Makefile
new file mode 100644
index 0000000000..c11c80dd2b
--- /dev/null
+++ b/util/optionlist/Makefile
@@ -0,0 +1,7 @@
+all:
+ ./mkOptionList.py
+ @#saxon Options.xml Options.xsl >Options.html
+ xsltproc Options.xsl Options.xml > Options.html
+
+clean:
+ rm Options.xml Options.html
diff --git a/util/optionlist/Options.xsl b/util/optionlist/Options.xsl
new file mode 100644
index 0000000000..3502a24e19
--- /dev/null
+++ b/util/optionlist/Options.xsl
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<!--<xsl:choose>
+<xsl:when test="system-property('xsl:vendor')='Transformiix'">
+-->
+<xsl:output method="xml"
+ doctype-public="PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN"
+ doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
+ encoding="utf-8"
+ indent="yes" />
+<!--
+</xsl:when>
+<xsl:otherwise>
+<xsl:output method="xhtml"
+ doctype-public="PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN"
+ doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
+ encoding="utf-8"
+ indent="yes" />
+</xsl:otherwise>
+</xsl:choose>
+-->
+
+<xsl:template match="/">
+<html>
+<head>
+<title>LinuxBIOS Options</title>
+</head>
+<body>
+<h2>LinuxBIOS Options</h2>
+<p>This is an automatically generated list of LinuxBIOS compile time
+options. Created at <xsl:value-of select="//creationdate"/>.</p>
+<table border="1">
+<tr bgcolor="#0975a7">
+<th align="left">Option</th>
+<th align="left">Comment</th>
+<th align="left">Default</th>
+<th align="left">Export</th>
+<th align="left">Format</th>
+</tr>
+<xsl:for-each select="options/option">
+<tr>
+<td><xsl:value-of select="@name"/></td>
+<td><xsl:value-of select="comment"/></td>
+<td><xsl:value-of select="default"/></td>
+<td><xsl:value-of select="export"/></td>
+<td><xsl:value-of select="format"/></td>
+</tr>
+</xsl:for-each>
+</table>
+</body>
+</html>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/util/optionlist/README b/util/optionlist/README
new file mode 100644
index 0000000000..655af616e4
--- /dev/null
+++ b/util/optionlist/README
@@ -0,0 +1,24 @@
+I would like to contribute the following to the LinuxBIOS wiki in case
+it's useable:
+
+1. I have written a rather small python script to convert the Options.lb
+ to a XML file which is much more useable for the web in most cases.
+
+2. I have written a XSLT to convert the XML file to (X)HTML to be able
+ to present it as a table.
+
+Florob (Florian Zeitz <florian-zeitz@lycos.de>)
+
+ChangeLog
+---------
+
+* 2005-03-19 stepan
+ - fix xml stylesheet to work with xsltproc and saxon
+ - add Makefile
+ - make script a bit more verbose
+
+* 2005-03-15 florob
+ - Initial version
+
+
+
diff --git a/util/optionlist/mkOptionList.py b/util/optionlist/mkOptionList.py
new file mode 100755
index 0000000000..c91f11aa22
--- /dev/null
+++ b/util/optionlist/mkOptionList.py
@@ -0,0 +1,123 @@
+#!/usr/bin/python
+
+def xmlString(string):
+ for i in range(len(string)-1):
+ if string[i] == "&":
+ string = string[:i] + "&amp;" + string[i+1:]
+ if string[i] == "<":
+ string = string[:i] + "&lt;" + string[i+1:]
+ if string[i] == ">":
+ string = string[:i] + "&gt;" + string[i+1:]
+ return string
+
+def openInfile(filename):
+ "getting the input from the inputfile (e.g. Options.lb)"
+ infile = open(filename, "r")
+ infile.seek(0)
+ input = infile.readlines()
+ infile.close()
+ return input
+
+def prepInput(input):
+ "preparing the input for parsing (not really neccessary, but makes things simpler and doesnt take too long)"
+ i = -1
+ while True:
+ i += 1
+ if i >= len(input): break
+ if input[i] == ("" or "\n"):
+ input.pop(i)
+ if input[i][0:1] == "\t":
+ input[i] = input[i][1:]
+ i = -1
+ return input
+
+def parseInput(input):
+ "parse the output"
+ output = ""
+ for line in input:
+ line = xmlString(line)
+ if line[:6] == "define":
+ output = output + '<option name="' + line[7:-1] + '">' + "\n"
+ elif line[:3] == "end":
+ output = output + '</option>' + "\n\n"
+ elif line[:7] == "default":
+ output = output + '<default>' + line[8:-1] + '</default>' + "\n"
+ elif line[:6] == "format":
+ output = output + '<format>' + line[7:-1] + '</format>' + "\n"
+ elif line[:6] == "export":
+ output = output + '<export>' + line[7:-1] + '</export>' + "\n"
+ elif line[:7] == "comment":
+ output = output + '<comment>' + line[8:-1] + '</comment>' + "\n"
+
+ return output
+
+def parseArgv():
+ "parse the given arguments"
+ import sys
+
+ In = Out = False
+
+ if len(sys.argv) >= 2:
+ if sys.argv[1] == ("-h" or "--help"):
+ print "Syntax: mkOptionList.py [infile] [outfile]"
+ else:
+ In = True
+ inFilename = sys.argv[1]
+ if len(sys.argv) >= 3:
+ if sys.argv[2] == ("-h" or "--help"):
+ print "Syntax: mkOptionList.py [infile] [outfile]"
+ else:
+ Out = True
+ outFilename = sys.argv[2]
+
+ if In and not Out:
+ return inFilename
+ elif In and Out:
+ return inFilename, outFilename
+
+
+def main():
+ import time
+ if not parseArgv():
+ inFilename = "../../src/config/Options.lb"
+ outFilename = "Options.xml"
+ else:
+ inFilename, outFilename = parseArgv()
+
+ input = openInfile(inFilename)
+ input = prepInput(input)
+ output = parseInput(input)
+
+ print "mkOptionList.py: LinuxBIOS option list generator"
+ print " input file : ", inFilename
+ print " output file: ", outFilename
+
+ #opening the output file
+ outfile = open(outFilename, "w", 0)
+
+ #write the beginning of the XML to the output file
+ outfile.write('<?xml version="1.0"?>')
+ outfile.write("\n")
+ outfile.write('<?xml-stylesheet type="text/xsl" href="Options.xsl"?>')
+ outfile.write("\n")
+ outfile.write('<options>')
+ outfile.write("\n")
+ outfile.write('<creationdate>')
+ outfile.write(time.strftime('%Y/%m/%d %H:%M:%S'))
+ outfile.write('</creationdate>')
+ outfile.write("\n")
+
+
+ #write the parsed file to the output file
+ outfile.write(output)
+
+ #write closing tags to the output file and close it
+ outfile.write('</options>')
+ outfile.write("\n")
+ outfile.flush()
+ outfile.close()
+
+ print "Done!"
+
+if __name__ == "__main__":
+ main()