#!/usr/bin/env python3 # -*- coding: utf-8 -*- import argparse import os import sys from msgutils import MsgHandlingIni def main(): parser = argparse.ArgumentParser( description='Tool for generating/updating the message handling INI from the inputted message conf file(s)' ) parser.add_argument('conf', nargs='+') parser.add_argument('output', help='path to the message handling INI to create or update') args = parser.parse_args() if len(sys.argv) < 3: parser.print_help() else: msg_ini = MsgHandlingIni() try: for conf in args.conf: msg_ini.loadConf(conf, clear=False) msg_ini.loadIni(args.output) output_dir = os.path.dirname(os.path.abspath(args.output)) os.makedirs(output_dir, exist_ok=True) msg_ini.write_ini(args.output) except Exception as e: print('Error: %s' % e) sys.exit(1) if __name__ == "__main__": # calling main function main()