summaryrefslogtreecommitdiff
path: root/gpscap.py
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-01-20 03:41:45 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-01-20 03:41:45 +0000
commit75be0201cb6ac504ea7a2159a66c31ad69a5d858 (patch)
tree7c961be504bab0b426c30c301579fbf7c15a3d5e /gpscap.py
parentc288fb6cc7e3e3c34461bcfe8b735745a91b32a8 (diff)
downloadgpsd-75be0201cb6ac504ea7a2159a66c31ad69a5d858.tar.gz
We can now generate a better hardware data dable fom the database.
Diffstat (limited to 'gpscap.py')
-rw-r--r--gpscap.py52
1 files changed, 51 insertions, 1 deletions
diff --git a/gpscap.py b/gpscap.py
index 7cb44812..9ebe8db8 100644
--- a/gpscap.py
+++ b/gpscap.py
@@ -37,11 +37,14 @@ class GPSDictionary(ConfigParser.RawConfigParser):
elif self.get(section, "type") not in ("engine", "vendor", "device"):
raise ConfigParser.Error("%s has invalid type" % section)
# Sanity check: All devices must point at a vendor object.
- # Side effect: build the list of vendors.
+ # Side effect: build the lists of vendors and devices.
self.vendors = []
+ self.devices = []
for section in self.sections():
if self.get(section, "type") == "vendor":
self.vendors.append(section)
+ if self.get(section, "type") == "device":
+ self.devices.append(section)
self.vendors.sort()
for section in self.sections():
if self.get(section, "type") == "device":
@@ -49,5 +52,52 @@ class GPSDictionary(ConfigParser.RawConfigParser):
raise ConfigParser.Error("%s has no vendor" % section)
if self.get(section, "vendor") not in self.vendors:
raise ConfigParser.Error("%s has invalid vendor" % section)
+
+ def HTMLDump(self, ofp):
+ thead = """<table border='1' style='font-size:small;'>
+<tr>
+<th>Name</th>
+<th>Packaging</th>
+<th>Engine</th>
+<th>Interface</th>
+<th>Tested with</th>
+<th>NMEA version</th>
+<th width='50%'>Notes</th>
+</tr>
+"""
+ vhead = "<tr><td style='text-align:center;' colspan='7'><a href='%s'>%s</a></td></tr>\n"
+ ofp.write(thead)
+ for vendor in self.vendors:
+ ofp.write(vhead % (self.get(vendor, "vendor_site"), vendor))
+ relevant = []
+ for dev in self.devices:
+ if self.get(dev, "vendor") == vendor:
+ relevant.append(dev)
+ relevant.sort()
+ for dev in relevant:
+ ofp.write("<tr>\n")
+ ofp.write("<td>%s</td>\n" % dev)
+ ofp.write("<td>%s</td>\n" % self.get(dev, "packaging"))
+ ofp.write("<td>%s</td>\n" % self.get(dev, "engine"))
+ ofp.write("<td>%s</td>\n" % self.get(dev, "interfaces"))
+ tested = ""
+ if self.has_option(dev, "broken"):
+ tested = "Broken"
+ elif self.get(dev, "tested") == "regression":
+ tested = "*"
+ else:
+ tested = self.get(dev, "tested")
+ ofp.write("<td>%s</td>\n" % tested)
+ nmea = "&nbsp;"
+ if self.has_option(dev, "nmea"):
+ nmea = self.get(dev, "nmea")
+ ofp.write("<td>%s</td>\n" % nmea)
+ ofp.write("<td>%s</td>\n" % self.get(dev, "notes"))
+ ofp.write("</tr>\n")
+ ofp.write("</table>\n")
+
+
if __name__ == "__main__":
+ import sys
d = GPSDictionary()
+ d.HTMLDump(sys.stdout)