6 parser = argparse.ArgumentParser(description='Process DBus mappings.')
7 parser.add_argument('mappingFiles', metavar='N', nargs='+',
8 help='dbus headers to find mappings in')
9 parser.add_argument('--output', dest='output',
10 help='output file to write idl to')
11 args = parser.parse_args()
13 print args.mappingFiles
24 return "{" + self.ambName + " => " + self.memberName + "}"
26 return ' const DOMString ' + self.ambName + ' = "' + self.memberName + '";\n'
33 return "Interface('" + name + "')"
35 output = self.name + ":"
36 for member in self.members:
37 output += member.toString() + ","
40 output = "interface " + self.name + " {\n"
41 for member in self.members:
42 output += member.toIdl()
46 for input in args.mappingFiles:
47 try: file = open(input)
49 print "Failed to open " + input
52 i = line.find("DBusSink(\"");
54 interface = Interface()
55 ifaceNameBeg = line.find('("')
56 ifaceNameEnd = line.find('",')
57 interface.name = line[ifaceNameBeg+2 : ifaceNameEnd]
58 interfaces.append(interface)
59 wantPropertyVariant = 'wantPropertyVariant('
60 i = line.find(wantPropertyVariant)
63 ambNameEnd = line.find(', "')-2
64 member.ambName = line[i+len(wantPropertyVariant) : i + ambNameEnd].replace("VehicleProperty::", "")
65 memberNameBeg = line.find(', "')+3
66 memberNameEnd = line.find('",')
67 member.memberName = line[memberNameBeg : memberNameEnd]
68 interfaces[-1].members.append(member)
71 try: outputFile = open(args.output, 'w')
73 print "Error could not open output file: " + args.output
76 " * \\name AMB to AMB-DBus Mapping Tables\n"
77 " * \\file " + os.path.basename(args.output) + "\n"
78 " * \\brief This describes the AMB internal property names to AMB DBus interface property names\n"
79 " * AMB internal property names are designed to be flat variable names (ie, 'ConvertableRoofStatus'). The DBus\n"
80 " * properties however follow the naming scheme defined in the W3C automotive business group vehicle <a href='http://w3c.github.io/automotive-bg/data_spec.html'>data specification</a>\n"
81 " * The pattern each interface is 'const DOMString AMBProperty = DBusProperty' where 'AMBProperty' is the internal name and 'DBusProperty' is the DBus property name")
83 outputFile.write(header)
84 for iface in interfaces:
85 outputFile.write(iface.toIdl())
86 outputFile.write("\n")