summaryrefslogtreecommitdiff
path: root/gpscap.py
diff options
context:
space:
mode:
Diffstat (limited to 'gpscap.py')
-rw-r--r--gpscap.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/gpscap.py b/gpscap.py
index 689fbdf6..7cb44812 100644
--- a/gpscap.py
+++ b/gpscap.py
@@ -30,6 +30,24 @@ class GPSDictionary(ConfigParser.RawConfigParser):
self.remove_option(section, "uses")
if not keepgoing:
break
-
+ # Sanity check: All items must have a type field.
+ 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"):
+ 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.
+ self.vendors = []
+ for section in self.sections():
+ if self.get(section, "type") == "vendor":
+ self.vendors.append(section)
+ self.vendors.sort()
+ for section in self.sections():
+ if self.get(section, "type") == "device":
+ if not self.has_option(section, "vendor"):
+ 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)
if __name__ == "__main__":
d = GPSDictionary()