def main(): argparser = build_argparser() args = argparser.parse_args() spec = Spec() for fn in args.files: with io.open(fn, 'r') as f: for t in parser.parse(f.read()): spec.add(t) parser.restart() spec.check_undefined() if args.output_type == 'unity': unitygen.generate(spec, sys.stdout, args.namespace) elif args.output_type == 'idlite': idlitegen.generate(spec, sys.stdout) else: sys.exit(""" Unknown output type: %r Available types are: unity, idlite""" % args.output_type)
def main(): argparser = build_argparser() args = argparser.parse_args() spec = [] for fn in args.files: with open(fn) as f: spec += parser.parse(f.read()) parser.restart() type_order = {types.Enum: 0, types.Class: 1} spec.sort(key=lambda s: (type_order[type(s)], s.name)) check_undefined(spec) if args.output_type == 'unity': unitygen.generate(spec, sys.stdout, args.namespace) elif args.output_type == 'idlite': idlitegen.generate(spec, sys.stdout) else: sys.exit(""" Unknown output type: %r Available types are: unity, idlite""" % args.output_type)