Beispiel #1
0
def eval_input_file(opts: argparse.Namespace) -> None:
    """ Evaluate an input XML or ShExC file
    :param opts: function arguments
    """
    with open(opts.infile) as inp_file:
        if opts.infile_format == "shex":
            parsed_shex = do_parse(InputStream(inp_file.read()))
            parsed_xml = prettyxml(parsed_shex.to_dom())
        else:
            parsed_xml = inp_file.read()
    g = Graph()
    g.parse(opts.graph, format=opts.graph_format)
    print("*** " +
          ("Success" if eval_shexml(parsed_xml, opts.start_shape, opts.focus_node, g, opts) else "NOMATCH") + "***")
Beispiel #2
0
def eval_manifest_entry(name: str, entries: Iterable, opts: argparse.Namespace) -> None:
    """ Evaluate a manifest entry
    :param name: name of the manifest entry
    :param entries: actual manifest entries (there can be more than one per name...)
    :param opts: function options
    """
    print("Evaluating: %s" % name)
    for entry in entries:
        print("   Entry: %s - " % entry.entryuri, end='')
        parsed_shex = do_parse(InputStream(entry.schema))
        parsed_xml = prettyxml(parsed_shex.to_dom())
        rslt = eval_shexml(parsed_xml, entry.start_shape, entry.subject_iri,
                               entry.instance(fmt=opts.graph_format), opts)
        print("PASS" if rslt == entry.should_pass else "FAIL")
Beispiel #3
0
def eval_manifest_entry(name: str, entries: Iterable,
                        opts: argparse.Namespace) -> None:
    """ Evaluate a manifest entry
    :param name: name of the manifest entry
    :param entries: actual manifest entries (there can be more than one per name...)
    :param opts: function options
    """
    print("Evaluating: %s" % name)
    for entry in entries:
        print("   Entry: %s - " % entry.entryuri, end='')
        parsed_shex = do_parse(InputStream(entry.schema))
        parsed_xml = prettyxml(parsed_shex.to_dom())
        rslt = eval_shexml(parsed_xml, entry.start_shape, entry.subject_iri,
                           entry.instance(fmt=opts.graph_format), opts)
        print("PASS" if rslt == entry.should_pass else "FAIL")
Beispiel #4
0
def eval_input_file(opts: argparse.Namespace) -> None:
    """ Evaluate an input XML or ShExC file
    :param opts: function arguments
    """
    with open(opts.infile) as inp_file:
        if opts.infile_format == "shex":
            parsed_shex = do_parse(InputStream(inp_file.read()))
            parsed_xml = prettyxml(parsed_shex.to_dom())
        else:
            parsed_xml = inp_file.read()
    g = Graph()
    g.parse(opts.graph, format=opts.graph_format)
    print("*** " +
          ("Success" if eval_shexml(parsed_xml, opts.start_shape, opts.
                                    focus_node, g, opts) else "NOMATCH") +
          "***")