コード例 #1
0
def main(argv: list):
    _curdir = os.path.join(os.getcwd(), os.path.dirname(__file__))
    sys.path.append(os.path.join(_curdir, '../../ECLparser/parser'))
    sys.path.append(os.path.join(_curdir, '../../ECLparser/parser_impl'))
    sys.path.append(os.path.join(_curdir, '../..'))
    sys.path.append(os.path.join(_curdir, '../../../../../CTS2/rf2db'))
    sys.path.append(os.path.join(_curdir, '../../../../../CTS2/ConfigManager'))
    from ECLparser.scripts.TestRig_mod import build_argparser, parse_args, do_parse
    from ECLparser.rf2_substrate.RF2_Substrate import RF2_Substrate
    from ECLparser.interpreter import i_expressionConstraint
    ss = RF2_Substrate()
    parser_args = build_argparser()
    parser_args.add_argument("-i", "--interp", help="Interpret output", action="store_true")
    parser_args.add_argument("-s", "--sql", help="Output SQL", action="store_true")
    opts = parse_args(parser_args, fixed_args + argv)
    cmdline = CmdLine()
    try:
        while True:
            print("Expression:")
            input_ = cmdline.text
            result = do_parse(opts, InputStream(input_))
            if not result:
                print("Not a valid ECL expression")
            elif opts.interp:
                try:
                    print_results(opts, input_, i_expressionConstraint(ss, result))
                except Exception as e:
                    print_results(opts, input_, None, e)
                    print("EXCEPTION")
    except EOFError:
        pass
コード例 #2
0
def main(argv: list):
    _curdir = os.path.join(os.getcwd(), os.path.dirname(__file__))
    sys.path.append(os.path.join(_curdir, '../../ECLparser/parser'))
    sys.path.append(os.path.join(_curdir, '../../ECLparser/parser_impl'))
    sys.path.append(os.path.join(_curdir, '../..'))
    from ECLparser.scripts.TestRig_mod import build_argparser, parse_args, do_parse

    parser_args = build_argparser()
    parser_args.add_argument("-i", "--interp", help="Interpret output", action="store_true")
    parser_args.add_argument("-d", "--dir", help="Test directory", default='.')
    parser_args.add_argument("-f", "--file", help="File pattern to match")
    parser_args.add_argument("-o", "--outdir", help="Output directory for recording expected results")
    parser_args.add_argument("-s", "--sql", help="Output SQL", action="store_true")
    opts = parse_args(parser_args, argv)
    nviewed = nfailed = nsuccess = nexceptions = 0
    for (dirpath, _, filenames) in os.walk(opts.dir):
        for fn in filenames:
            if not fn.startswith('.') and not fn.endswith('.output') and (not opts.file or fn.startswith(opts.file)):
                print("PARSING: " + fn)
                result = do_parse(opts, FileStream(os.path.join(dirpath, fn)))
                nviewed += 1
                if not result:
                    print("FAILED")
                    nfailed += 1
                elif opts.interp:
                    # try:
                        print_results(opts, dirpath, fn, i_expressionConstraint(ss, result))
                        print("SUCCESS")
                        nsuccess += 1
                    # except Exception as e:
                    #     print_results(opts, dirpath, fn, None, e)
                    #     print("EXCEPTION")
                    #     nexceptions += 1
    print("Parsed %s files:" % nviewed)
    print("\tSuccess: %s" % nsuccess)
    print("\tParse Failure: %s" % nfailed)
    print("\tEvaluation Failure: %s" % nexceptions)