blob: 689fbdf693580e1e1a77ebd70a74faf38050bfcf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
"""
gpscap - GPS capability dictionary class.
"""
import ConfigParser
class GPSDictionary(ConfigParser.RawConfigParser):
def __init__(self, *files):
"Initialize the capability dictionary"
ConfigParser.RawConfigParser.__init__(self)
if not files:
files = ["gpscap.ini", "/usr/share/gpsd/gpscap.ini"]
self.read(files)
# Resolve uses= members
while True:
keepgoing = False
for section in self.sections():
if self.has_option(section, "uses"):
parent = self.get(section, "uses")
if self.has_option(parent, "uses"):
continue
# Found a parent section without a uses = part.
for heritable in self.options(parent):
if not self.has_option(section, heritable):
self.set(section,
heritable,
self.get(parent, heritable))
keepgoing = True
self.remove_option(section, "uses")
if not keepgoing:
break
if __name__ == "__main__":
d = GPSDictionary()
|