for k,v in common_objects.items():
    if (len(v)) > 1:
        common_payloads[v[0][0].name] = k
        for obj,scheme in v:
            try:
                common_objects_depends[obj.name] |= obj.struct_depends
            except:
                common_objects_depends[obj.name] = set(obj.struct_depends)

            to_remove = [ o for o in scheme.objects if o.payload == k ]
            for x in to_remove:
                scheme.objects.remove(x)

common_file = ocpp2_schema.HeaderFile(args.common_header, args.namespace, args.include)
common_file.write_header()
common_file.write_using()
for k,v in sorted(common_enums.items()):
    if (len(v)) > 1:
        for scheme in v:
            to_remove = [ e for e in scheme.enums if e.payload == k ]
            for x in to_remove:
                scheme.enums.remove(x)
        
        common_file.write(k)

while len(common_objects_depends):
    action = False
    for k,s in sorted(common_objects_depends.items()):
        if not len(s):
Ejemplo n.º 2
0
                            help="namespaces, in order")
parser.add_argument("--include", action="append",default=[],
                            help="header includes... e.g <vector>, \"foo.hpp\"")

args = parser.parse_args()

# this is not technically always needed...TODO
args.include.append("<vector>")


# note the 1:... weird utf foo at start of string
input_str = " ".join([line.strip() for line in open(args.input).readlines()])[1:]
schema = json.loads(input_str)


output_file = ocpp2_schema.HeaderFile(args.output, args.namespace, args.include)
output_file.write_header()
output_file.write_using()

scheme = ocpp2_schema.Scheme()

candidates = []
master_name = schema["$id"].split(":")[-1]
if "properties" not in schema.keys(): schema["properties"] = {}

if schema["type"] == "object":
    scheme.objects.append(ocpp2_schema.create("Object", name=master_name, attributes=schema, master=master_name))
    candidates.extend([[name,attributes] for name,attributes in schema["properties"].items()])
else:
    raise Exception("unexpected type in schema")