From 907f00190c17ee08d23f23f858f5ce8d3dcf330c Mon Sep 17 00:00:00 2001 From: "Gary E. Miller" Date: Sat, 1 Jul 2017 16:35:54 -0700 Subject: gpscap.py: pep8 fixes --- gpscap.py | 77 ++++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 23 deletions(-) (limited to 'gpscap.py') diff --git a/gpscap.py b/gpscap.py index 51f7c6d8..9dfa8baa 100644 --- a/gpscap.py +++ b/gpscap.py @@ -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 = """ + thead = """ +
@@ -78,13 +81,16 @@ class GPSDictionary(configparser.RawConfigParser): """ - vhead1 = "\n" - vhead2 = "\n" + vhead1 = "\n" + vhead2 = "\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("\n" % rowcolor) + ofp.write("\n" % rowcolor) namefield = dev if self.has_option(dev, "techdoc"): - namefield = "%s" % (self.get(dev, "techdoc"), dev) - if self.has_option(dev, "discontinued") and self.getboolean(dev, "discontinued"): - namefield = namefield + " Discontinued icon" + namefield = "%s" \ + % (self.get(dev, "techdoc"), dev) + if ((self.has_option(dev, "discontinued") + and self.getboolean(dev, "discontinued"))): + namefield = namefield + " " ofp.write("\n" % namefield) ofp.write("\n" % self.get(dev, "packaging")) engine = self.get(dev, "engine") if self.has_option(engine, "techdoc"): - engine = "%s" % (self.get(engine, "techdoc"), engine) + engine = "%s" \ + % (self.get(engine, "techdoc"), engine) if self.has_option(dev, "subtype"): engine += " (" + self.get(dev, "subtype") + ")" ofp.write("\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 += "Regression-test icon" + testfield += "" else: testfield += tested - if self.has_option(dev, "configurable") and self.get(dev, "configurable") == 'insane': - testfield += "No-configure icon" + if ((self.has_option(dev, "configurable") + and self.get(dev, "configurable") == 'insane')): + testfield += "" if self.get(dev, "rating") == "excellent": - testfield += "Star iconStar iconStar iconStar icon" + testfield += "Star icon" \ + "Star icon" \ + "Star icon" \ + "Star icon" elif self.get(dev, "rating") == "good": - testfield += "Star iconStar iconStar icon" + testfield += "Star icon" \ + "Star icon" \ + "Star icon" elif self.get(dev, "rating") == "fair": - testfield += "Star iconStar icon" + testfield += "Star icon" \ + "Star icon" elif self.get(dev, "rating") == "poor": testfield += "Star icon" elif self.get(dev, "rating") == "broken": - testfield += "Bomb icon" - if self.has_option(dev, "usbchip") and self.get(dev, "usbchip") in hotpluggables: - testfield += "Hotplug icon" + testfield += "Bomb icon" + if ((self.has_option(dev, "usbchip") + and self.get(dev, "usbchip") in hotpluggables)): + testfield += "Hotplug icon" ofp.write("\n" % testfield) nmea = " " if self.has_option(dev, "nmea"): nmea = self.get(dev, "nmea") ofp.write("\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("\n" % (pps_accuracy, time_offset)) + ofp.write("\n" + % (pps_accuracy, time_offset)) else: ofp.write("\n" % notes) + notes += " Reported by %s." % self.get( + dev, "submitter").replace("@", "@").replace( + "<", "<").replace(">", ">") + ofp.write("\n" % notes) ofp.write("\n") ofp.write("
Listing %s devices from %s vendors
NameNotes
%s
%s

%s

" \ + "%s
" \ + "%s

%s

%s%s%s%s%s%s
%s
%s
%s
?
\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("
%s%s
\n") -- cgit v1.2.1