#!/usr/bin/env python3 # -*- coding: utf-8 -*- import argparse import os import sys from msgutils import MsgProtobuf def main(): parser = argparse.ArgumentParser( description='Tool for generating the protobuf input file from the inputted message conf file' ) parser.add_argument('--output_dir', help='output directory for the generated Protobuf file', default='.') parser.add_argument('--namespace', help='namespace for protobuf package definition') parser.add_argument('conf', nargs='+', help='conf input file') parser.add_argument('protobuf', help='filename of outputted Protobuf file') args = parser.parse_args() if len(sys.argv) < 2: parser.print_help() else: msg_protobuf = MsgProtobuf() try: for conf in args.conf: msg_protobuf.loadConf(conf) if args.output_dir is not None: os.makedirs(args.output_dir, exist_ok=True) msg_protobuf.write_proto(args.protobuf, args.namespace, args.output_dir) except Exception as e: print('Error: %s' % e) sys.exit(1) # msg_data.dump() if __name__ == "__main__": # calling main function main()