diff options
author | Gary E. Miller <gem@rellim.com> | 2017-07-01 16:35:54 -0700 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2017-07-01 16:35:54 -0700 |
commit | 907f00190c17ee08d23f23f858f5ce8d3dcf330c (patch) | |
tree | 22c05b0cac89949ad3d42d5dd6a8a37d1a6239b5 /gpscap.py | |
parent | 6dcdf5ab01548194e4a927f0c8c4fa4abe45c709 (diff) | |
download | gpsd-907f00190c17ee08d23f23f858f5ce8d3dcf330c.tar.gz |
gpscap.py: pep8 fixes
Diffstat (limited to 'gpscap.py')
-rw-r--r-- | gpscap.py | 77 |
1 files changed, 54 insertions, 23 deletions
@@ -13,6 +13,7 @@ try: except ImportError: import ConfigParser as configparser + class GPSDictionary(configparser.RawConfigParser): def __init__(self, *files): "Initialize the capability dictionary" @@ -45,7 +46,8 @@ class GPSDictionary(configparser.RawConfigParser): for section in self.sections(): if not self.has_option(section, "type"): raise configparser.Error("%s has no type" % section) - elif self.get(section, "type") not in ("engine", "vendor", "device"): + 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 lists of vendors and devices. @@ -65,7 +67,8 @@ class GPSDictionary(configparser.RawConfigParser): raise configparser.Error("%s has invalid vendor" % section) def HTMLDump(self, ofp): - thead = """<table style='border:1px solid gray;font-size:small;background-color:#CCCCCC'> + thead = """ +<table style='border:1px solid gray;font-size:small;background-color:#CCCCCC'> <caption>Listing %s devices from %s vendors</caption> <tr> <th>Name</th> @@ -78,13 +81,16 @@ class GPSDictionary(configparser.RawConfigParser): <th style='width:50%%'>Notes</th> </tr> """ - vhead1 = "<tr><td style='text-align:center;' colspan='8'><a href='%s'>%s</a></td></tr>\n" - vhead2 = "<tr><td style='text-align:center;' colspan='8'><a href='%s'>%s</a><br><p>%s</p></td></tr>\n" + vhead1 = "<tr><td style='text-align:center;' colspan='8'>" \ + "<a href='%s'>%s</a></td></tr>\n" + vhead2 = "<tr><td style='text-align:center;' colspan='8'>" \ + "<a href='%s'>%s</a><br><p>%s</p></td></tr>\n" hotpluggables = ("pl2303", "CP2101") ofp.write(thead % (len(self.devices), len(self.vendors))) for vendor in self.vendors: if self.has_option(vendor, "notes"): - ofp.write(vhead2 % (self.get(vendor, "vendor_site"), vendor, self.get(vendor, "notes"))) + ofp.write(vhead2 % (self.get(vendor, "vendor_site"), vendor, + self.get(vendor, "notes"))) else: ofp.write(vhead1 % (self.get(vendor, "vendor_site"), vendor)) relevant = [] @@ -103,17 +109,23 @@ class GPSDictionary(configparser.RawConfigParser): elif self.get(dev, "packaging") == "hansdfree": rowcolor = "#008B8B" - ofp.write("<tr itemscope itemtype='http://schema.org/Product' style='background-color:%s'>\n" % rowcolor) + ofp.write("<tr itemscope itemtype='http://schema.org/Product'" + " style='background-color:%s'>\n" % rowcolor) namefield = dev if self.has_option(dev, "techdoc"): - namefield = "<a href='%s'>%s</a>" % (self.get(dev, "techdoc"), dev) - if self.has_option(dev, "discontinued") and self.getboolean(dev, "discontinued"): - namefield = namefield + " <img title='Device discontinued' src='discontinued.png' alt='Discontinued icon'>" + namefield = "<a href='%s'>%s</a>" \ + % (self.get(dev, "techdoc"), dev) + if ((self.has_option(dev, "discontinued") + and self.getboolean(dev, "discontinued"))): + namefield = namefield + " <img title='Device " \ + "discontinued' src='discontinued.png' " \ + "alt='Discontinued icon'>" ofp.write("<td itemprop='name'>%s</td>\n" % namefield) ofp.write("<td>%s</td>\n" % self.get(dev, "packaging")) engine = self.get(dev, "engine") if self.has_option(engine, "techdoc"): - engine = "<a href='%s'>%s</a>" % (self.get(engine, "techdoc"), engine) + engine = "<a href='%s'>%s</a>" \ + % (self.get(engine, "techdoc"), engine) if self.has_option(dev, "subtype"): engine += " (" + self.get(dev, "subtype") + ")" ofp.write("<td>%s</td>\n" % engine) @@ -125,36 +137,52 @@ class GPSDictionary(configparser.RawConfigParser): if self.has_option(dev, "tested"): tested = self.get(dev, "tested") if tested == "regression": - testfield += "<img title='Have regression test' src='regression.png' alt='Regression-test icon'>" + testfield += "<img title='Have regression test' " \ + "src='regression.png' " \ + "alt='Regression-test icon'>" else: testfield += tested - if self.has_option(dev, "configurable") and self.get(dev, "configurable") == 'insane': - testfield += "<img title='Requires -b option' src='noconfigure.png' alt='No-configure icon'>" + if ((self.has_option(dev, "configurable") + and self.get(dev, "configurable") == 'insane')): + testfield += "<img title='Requires -b option' " \ + "src='noconfigure.png' " \ + "alt='No-configure icon'>" if self.get(dev, "rating") == "excellent": - testfield += "<img src='star.png' alt='Star icon'><img src='star.png' alt='Star icon'><img src='star.png' alt='Star icon'><img src='star.png' alt='Star icon'>" + testfield += "<img src='star.png' alt='Star icon'>" \ + "<img src='star.png' alt='Star icon'>" \ + "<img src='star.png' alt='Star icon'>" \ + "<img src='star.png' alt='Star icon'>" elif self.get(dev, "rating") == "good": - testfield += "<img src='star.png' alt='Star icon'><img src='star.png' alt='Star icon'><img src='star.png' alt='Star icon'>" + testfield += "<img src='star.png' alt='Star icon'>" \ + "<img src='star.png' alt='Star icon'>" \ + "<img src='star.png' alt='Star icon'>" elif self.get(dev, "rating") == "fair": - testfield += "<img src='star.png' alt='Star icon'><img src='star.png' alt='Star icon'>" + testfield += "<img src='star.png' alt='Star icon'>" \ + "<img src='star.png' alt='Star icon'>" elif self.get(dev, "rating") == "poor": testfield += "<img src='star.png' alt='Star icon'>" elif self.get(dev, "rating") == "broken": - testfield += "<img title='Device is broken' src='bomb.png' alt='Bomb icon'>" - if self.has_option(dev, "usbchip") and self.get(dev, "usbchip") in hotpluggables: - testfield += "<img title='udev hotplug' src='hotplug.png' alt='Hotplug icon'>" + testfield += "<img title='Device is broken' " \ + "src='bomb.png' alt='Bomb icon'>" + if ((self.has_option(dev, "usbchip") + and self.get(dev, "usbchip") in hotpluggables)): + testfield += "<img title='udev hotplug' " \ + "src='hotplug.png' alt='Hotplug icon'>" ofp.write("<td>%s</td>\n" % testfield) nmea = " " if self.has_option(dev, "nmea"): nmea = self.get(dev, "nmea") ofp.write("<td>%s</td>\n" % nmea) - if self.has_option(dev, "pps") and self.get(dev, "pps") == "True": + if ((self.has_option(dev, "pps") + and self.get(dev, "pps") == "True")): pps_accuracy = time_offset = "" if self.has_option(dev, "pps_accuracy"): pps_accuracy = self.get(dev, "pps_accuracy") if self.has_option(dev, "time_offset"): time_offset = self.get(dev, "time_offset") if pps_accuracy and time_offset: - ofp.write("<td>%s<br>%s</td>\n" % (pps_accuracy, time_offset)) + ofp.write("<td>%s<br>%s</td>\n" + % (pps_accuracy, time_offset)) else: ofp.write("<td>?<br>\n") else: @@ -164,8 +192,11 @@ class GPSDictionary(configparser.RawConfigParser): else: notes = "" if self.has_option(dev, "submitter"): - notes += " Reported by %s." % self.get(dev, "submitter").replace("@", "@").replace("<", "<").replace(">", ">") - ofp.write("<td itemscope itemtype='http://schema.org/description'>%s</td>\n" % notes) + notes += " Reported by %s." % self.get( + dev, "submitter").replace("@", "@").replace( + "<", "<").replace(">", ">") + ofp.write("<td itemscope itemtype='http://schema.org/" + "description'>%s</td>\n" % notes) ofp.write("</tr>\n") ofp.write("</table>\n") |