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
21 def __init__(self, ifaceName):
22 self.interfaceName = ifaceName
26 return "{" + self.ambName + " => " + self.memberName + "}"
31 idl.append('\t * \\brief corresponds with DBus property ' + self.memberName + ' for interface org.automotive.' + self.interfaceName)
32 idl.append('\t * AMB fulfills this member with VehicleProperty::' + self.ambName)
34 idl.append('\tconst DOMString ' + self.ambName + ' = "' + self.memberName + '";\n')
42 return "Interface('" + name + "')"
44 output = self.name + ":"
45 for member in self.members:
46 output += member.toString() + ","
49 output = "/*! \n * \\brief Corresponds with DBus Interface org.automotive." + self.name + "\n */\ninterface " + self.name + " {\n"
50 for member in self.members:
51 output += member.toIdl()
55 for input in args.mappingFiles:
56 try: file = open(input)
58 print "Failed to open " + input
61 i = line.find("DBusSink(\"");
63 interface = Interface()
64 ifaceNameBeg = line.find('("')
65 ifaceNameEnd = line.find('",')
66 interface.name = line[ifaceNameBeg+2 : ifaceNameEnd]
67 interfaces.append(interface)
68 wantPropertyVariant = 'wantPropertyVariant('
69 i = line.find(wantPropertyVariant)
71 member = Member(interfaces[-1].name)
72 ambNameEnd = line.find(', "')-2
73 member.ambName = line[i+len(wantPropertyVariant) : i + ambNameEnd].replace("VehicleProperty::", "")
74 memberNameBeg = line.find(', "')+3
75 memberNameEnd = line.find('",')
76 member.memberName = line[memberNameBeg : memberNameEnd]
77 interfaces[-1].members.append(member)
80 try: outputFile = open(args.output, 'w')
82 print "Error could not open output file: " + args.output
85 " * \\name AMB to AMB-DBus Mapping Tables\n"
86 " * \\file " + os.path.basename(args.output) + "\n"
87 " * \\brief This describes the AMB internal property names to AMB DBus interface property names\n"
88 " * AMB internal property names are designed to be flat variable names (ie, 'ConvertableRoofStatus'). The DBus\n"
89 " * 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"
90 " * The pattern each interface is 'const DOMString AMBProperty = DBusProperty' where 'AMBProperty' is the internal name and 'DBusProperty' is the DBus property name.\n"
92 " * For documentation on the interface and members, please see the \ref dbus_api.\n")
94 outputFile.write(header)
95 for iface in interfaces:
96 outputFile.write(iface.toIdl())
97 outputFile.write("\n")