params['nonempty'] = len(argblocks) ofd.write(templ.substitute(params)) if __name__ == '__main__': import argparse argp = argparse.ArgumentParser(description = 'FRR CLI preprocessor in Python') argp.add_argument('--all-defun', action = 'store_const', const = True, help = 'process DEFUN() statements in addition to DEFPY()') argp.add_argument('--show', action = 'store_const', const = True, help = 'print out list of arguments and types for each definition') argp.add_argument('-o', type = str, metavar = 'OUTFILE', help = 'output C file name') argp.add_argument('cfile', type = str) args = argp.parse_args() dumpfd = None if args.o is not None: ofd = StringIO() if args.show: dumpfd = sys.stdout else: ofd = sys.stdout if args.show: dumpfd = sys.stderr process_file(args.cfile, ofd, dumpfd, args.all_defun) if args.o is not None: clippy.wrdiff(args.o, ofd, [args.cfile, os.path.realpath(__file__)])
argp.add_argument('--all-defun', action='store_const', const=True, help='process DEFUN() statements in addition to DEFPY()') argp.add_argument( '--show', action='store_const', const=True, help='print out list of arguments and types for each definition') argp.add_argument('-o', type=str, metavar='OUTFILE', help='output C file name') argp.add_argument('cfile', type=str) args = argp.parse_args() dumpfd = None if args.o is not None: ofd = StringIO() if args.show: dumpfd = sys.stdout else: ofd = sys.stdout if args.show: dumpfd = sys.stderr process_file(args.cfile, ofd, dumpfd, args.all_defun) if args.o is not None: clippy.wrdiff(args.o, ofd)
dumpfd = None if args.o is not None: ofd = StringIO() if args.show: dumpfd = sys.stdout else: ofd = sys.stdout if args.show: dumpfd = sys.stderr basepath = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) macros = Macros() macros.load("lib/route_types.h") macros.load(os.path.join(basepath, "lib/command.h")) macros.load(os.path.join(basepath, "bgpd/bgp_vty.h")) # sigh :( macros["PROTO_REDIST_STR"] = "FRR_REDIST_STR_ISISD" macros["PROTO_IP_REDIST_STR"] = "FRR_IP_REDIST_STR_ISISD" macros["PROTO_IP6_REDIST_STR"] = "FRR_IP6_REDIST_STR_ISISD" errors = process_file(args.cfile, ofd, dumpfd, args.all_defun, macros) if errors != 0: sys.exit(1) if args.o is not None: clippy.wrdiff(args.o, ofd, [args.cfile, os.path.realpath(__file__), sys.executable])
params['nonempty'] = len(argblocks) ofd.write(templ.substitute(params)) if __name__ == '__main__': import argparse argp = argparse.ArgumentParser(description = 'FRR CLI preprocessor in Python') argp.add_argument('--all-defun', action = 'store_const', const = True, help = 'process DEFUN() statements in addition to DEFPY()') argp.add_argument('--show', action = 'store_const', const = True, help = 'print out list of arguments and types for each definition') argp.add_argument('-o', type = str, metavar = 'OUTFILE', help = 'output C file name') argp.add_argument('cfile', type = str) args = argp.parse_args() dumpfd = None if args.o is not None: ofd = StringIO() if args.show: dumpfd = sys.stdout else: ofd = sys.stdout if args.show: dumpfd = sys.stderr process_file(args.cfile, ofd, dumpfd, args.all_defun) if args.o is not None: clippy.wrdiff(args.o, ofd, [args.cfile, os.path.realpath(__file__), sys.executable])