예제 #1
0
async def cc_report(args):

    if args.verbose > 1:
        print(f'Checking OPeNDAP URL: {url}')

    if args.format == 'summary':
        cs = CheckSuite()
        if args.criteria == 'normal':
            limit = 2
        elif args.criteria == 'strict':
            limit = 1
        elif args.criteria == 'lenient':
            limit = 3


        ds = cs.load_dataset(url)
        skip_checks = ()
        score_groups = cs.run(ds, skip_checks, *args.test)

        # Always use sorted test (groups) so they print in correct order
        reports = {}
        for checker, rpair in sorted(score_groups.items()):
            groups, _ = rpair
            _, points, out_of = cs.get_points(groups, limit)
            reports[checker] = (100 * float(points) / float(out_of))

        print((report_fmt).format(url, *[reports[t] for t in sorted(args.test)]))
        sys.stdout.flush()
    else:
        # Send the compliance report to stdout
        ComplianceChecker.run_checker(url, args.test, args.verbose, args.criteria,
                                        args.output, args.format)
예제 #2
0
def main(args):
    if args.format == 'summary':
        hdr_fmt = '{},' * len(args.test)
        rpt_fmt = '{:.1f},' * len(args.test)
        report_fmt = '{},' + rpt_fmt[:-1]
        print(('{},' + hdr_fmt[:-1]).format('url', *sorted(args.test)))

    for cat in args.catalog_urls:
        if args.verbose > 1:
            print(f'Opening catalog_url: {cat}')
        for url in get_opendap_urls(cat):

            if args.verbose > 1:
                print(f'Checking OPeNDAP URL: {url}')

            if args.format == 'summary':
                cs = CheckSuite()
                if args.criteria == 'normal':
                    limit = 2
                elif args.criteria == 'strict':
                    limit = 1
                elif args.criteria == 'lenient':
                    limit = 3

                try:
                    ds = cs.load_dataset(url)
                except ValueError as e:
                    print(f'Failed to get report for {url}')
                    print(str(e))
                    continue
                    
                skip_checks = ()
                score_groups = cs.run(ds, skip_checks, *args.test)
                

                # Always use sorted test (groups) so they print in correct order
                reports = {}
                for checker, rpair in sorted(score_groups.items()):
                    groups, _ = rpair
                    _, points, out_of = cs.get_points(groups, limit)
                    reports[checker] = (100 * float(points) / float(out_of))

                print((report_fmt).format(url, *[reports[t] for t in sorted(args.test)]))
                sys.stdout.flush()

            else:
                # Send the compliance report to stdout
                ComplianceChecker.run_checker(url, args.test, args.verbose, args.criteria,
                                              args.output, args.format)