def make_generic_messages(self, datagraph: GraphLike, focus_node, value_node) -> List[rdflib.Literal]: if len(self.min_vals) < 2: m = "Value is not > {}".format(stringify_node(self.shape.sg.graph, self.min_vals[0])) else: rules = ", ".join(stringify_node(self.shape.sg.graph, c) for c in self.min_vals) m = "Value is not > in ({})".format(rules) return [rdflib.Literal(m)]
def make_generic_messages(self, datagraph: GraphLike, focus_node, value_node) -> List[rdflib.Literal]: or_list = " , ".join( stringify_node(self.shape.sg.graph, o_c) for o in self.or_list for o_c in self.shape.sg.graph.items(o) ) m = "Node {} does not conform to one or more shapes in {}".format( stringify_node(datagraph, value_node), or_list ) return [rdflib.Literal(m)]
def make_generic_messages(self, datagraph: GraphLike, focus_node, value_node) -> List[rdflib.Literal]: list1 = [ stringify_node(self.shape.sg.graph, val) for val in self.in_vals ] m = "Value {} not in list {}".format( stringify_node(datagraph, value_node), list1) return [rdflib.Literal(m)]
def make_generic_messages(self, datagraph: GraphLike, focus_node, value_node) -> List[rdflib.Literal]: xone_list = " , ".join( stringify_node(self.shape.sg.graph, a_c) for a in self.xone_nodes for a_c in self.shape.sg.graph.items(a)) m = "Node {} does not conform to exactly one shape in {}".format( stringify_node(datagraph, value_node), xone_list) return [rdflib.Literal(m)]
def make_generic_messages(self, datagraph: GraphLike, focus_node, value_node) -> List[rdflib.Literal]: and_list = " , ".join( stringify_node(self.shape.sg.graph, a_c) for a in self.and_list for a_c in self.shape.sg.graph.items(a)) m = "Node {} does not conforms to all shapes in {}".format( stringify_node(datagraph, value_node), and_list) return [rdflib.Literal(m)]
def make_generic_messages(self, datagraph: GraphLike, focus_node, value_node) -> List[Literal]: p = self.shape.path() if p: p = stringify_node(self.shape.sg.graph, p) m = "Less than {} values on {}->{}".format( str(self.min_count.value), stringify_node(datagraph, focus_node), p ) else: m = "Less than {} values on {}".format(str(self.min_count.value), stringify_node(datagraph, focus_node)) return [Literal(m)]
def make_generic_messages(self, datagraph: GraphLike, focus_node, value_node) -> List[rdflib.Literal]: if len(self.node_shapes) < 2: m = "Value does not conform to Shape {}".format( stringify_node(self.shape.sg.graph, self.node_shapes[0])) else: rules = "', '".join( stringify_node(self.shape.sg.graph, self.node_shapes[0]) for c in self.node_shapes) m = "Value does not conform to every Shape in ('{}')".format(rules) return [rdflib.Literal(m)]
def make_generic_messages(self, datagraph: GraphLike, focus_node, value_node) -> List[Literal]: if len(self.class_rules) < 2: m = "Value does not have class {}".format( stringify_node(self.shape.sg.graph, self.class_rules[0])) else: rules = ", ".join( stringify_node(self.shape.sg.graph, c) for c in self.class_rules) m = "Value class is not in classes ({})".format(rules) return [Literal(m)]
def make_generic_messages(self, datagraph: GraphLike, focus_node, value_node) -> List[rdflib.Literal]: the_set = [ stringify_node(self.shape.sg.graph, s) for s in self.has_value_set ] p = self.shape.path() if p: p = stringify_node(self.shape.sg.graph, p) m = "Node {}->{} does not contain a value in the set: {}".format( stringify_node(datagraph, focus_node), p, the_set) else: m = "Node {} value is not a in the set of values: {}".format( stringify_node(datagraph, focus_node), the_set) return [rdflib.Literal(m)]
def make_generic_messages(self, datagraph: GraphLike, focus_node, value_node) -> List[rdflib.Literal]: if len(self.property_compare_set) < 2: m = "Value of {}->{} < {}".format( stringify_node(datagraph, focus_node), stringify_node(self.shape.sg.graph, next(iter(self.property_compare_set))), stringify_node(datagraph, value_node), ) else: rules = ", ".join(stringify_node(self.shape.sg.graph, p) for p in self.property_compare_set) m = "Value of {}->{} < {}".format( stringify_node(datagraph, focus_node), rules, stringify_node(datagraph, value_node) ) return [rdflib.Literal(m)]
def make_v_result_description(self, severity, focus_node, value_node=None, result_path=None, constraint_component=None, source_constraint=None, extra_messages=None): sg = self.shape.sg.graph constraint_component = constraint_component or self.shacl_constraint_class() constraint_name = self.constraint_name() if severity == SH_Violation: severity_desc = "Constraint Violation" else: severity_desc = "Constraint Report" source_shape_text = stringify_node(sg, self.shape.node) focus_node_text = stringify_node(sg, focus_node) severity_node_text = stringify_node(sg, severity) desc = "{} in {} ({}):\n\tSeverity: {}\n\tSource Shape: {}\n\tFocus Node: {}\n"\ .format(severity_desc, constraint_name, str(constraint_component), severity_node_text, source_shape_text, focus_node_text) if value_node is not None: val_node_string = stringify_node(sg, value_node) desc += "\tValue Node: {}\n".format(val_node_string) if result_path is None and self.shape.is_property_shape: result_path = self.shape.path() if result_path: result_path_text = stringify_node(sg, result_path) desc += "\tResult Path: {}\n".format(result_path_text) if source_constraint: sc_text = stringify_node(sg, source_constraint) desc += "\tSource Constraint: {}\n".format(sc_text) if extra_messages: for m in iter(extra_messages): if m in self.shape.message: continue if isinstance(m, rdflib.Literal): desc += "\tMessage: {}\n".format(str(m.value)) else: # pragma: no cover desc += "\tMessage: {}\n".format(str(m)) for m in self.shape.message: if isinstance(m, rdflib.Literal): desc += "\tMessage: {}\n".format(str(m.value)) else: # pragma: no cover desc += "\tMessage: {}\n".format(str(m)) return desc
def make_generic_messages(self, datagraph: GraphLike, focus_node, value_node) -> List[rdflib.Literal]: m = "String language is not in {}".format( stringify_node(datagraph, self.string_rules[0])) return [rdflib.Literal(m)]
def make_v_result_description( self, datagraph: GraphLike, focus_node: 'rdflib.term.Identifier', severity: URIRef, value_node: Optional['rdflib.term.Identifier'], messages: List[str], result_path=None, constraint_component=None, source_constraint=None, extra_messages: Optional[Iterable] = None, ): """ :param datagraph: :type datagraph: rdflib.Graph | rdflib.ConjunctiveGraph | rdflib.Dataset :param focus_node: :type focus_node: rdflib.term.Identifier :param severity: :type value_node: rdflib.URIRef :param value_node: :type value_node: rdflib.term.Identifier | None :param messages: :type messages: List[str] :param result_path: :param constraint_component: :param source_constraint: :param extra_messages: :type extra_messages: collections.abc.Iterable | None :return: """ sg = self.shape.sg.graph constraint_component = constraint_component or self.shacl_constraint_class( ) constraint_name = self.constraint_name() if severity == SH_Violation: severity_desc = "Constraint Violation" else: severity_desc = "Validation Result" source_shape_text = stringify_node(sg, self.shape.node) severity_node_text = stringify_node(sg, severity) focus_node_text = stringify_node(datagraph or sg, focus_node) desc = "{} in {} ({}):\n\tSeverity: {}\n\tSource Shape: {}\n\tFocus Node: {}\n".format( severity_desc, constraint_name, str(constraint_component), severity_node_text, source_shape_text, focus_node_text, ) if value_node is not None: val_node_string = stringify_node(datagraph or sg, value_node) desc += "\tValue Node: {}\n".format(val_node_string) if result_path is None and self.shape.is_property_shape: result_path = self.shape.path() if result_path: result_path_text = stringify_node(sg, result_path) desc += "\tResult Path: {}\n".format(result_path_text) if source_constraint: sc_text = stringify_node(sg, source_constraint) desc += "\tSource Constraint: {}\n".format(sc_text) if extra_messages: for m in iter(extra_messages): if m in messages: continue if isinstance(m, Literal): desc += "\tMessage: {}\n".format(str(m.value)) else: # pragma: no cover desc += "\tMessage: {}\n".format(str(m)) for m in messages: if isinstance(m, Literal): desc += "\tMessage: {}\n".format(str(m.value)) else: # pragma: no cover desc += "\tMessage: {}\n".format(str(m)) return desc
def make_generic_messages(self, datagraph: GraphLike, focus_node, value_node) -> List[rdflib.Literal]: m = "Node {} conforms to shape {}".format( stringify_node(datagraph, value_node), stringify_node(self.shape.sg.graph, self.not_list[0]) ) return [rdflib.Literal(m)]
def make_generic_messages(self, datagraph: GraphLike, focus_node, value_node) -> List[rdflib.Literal]: m = "Node {} is closed. It cannot have value: {}".format( stringify_node(datagraph, focus_node), stringify_node(datagraph, value_node)) return [rdflib.Literal(m)]
def make_generic_messages(self, datagraph: GraphLike, focus_node, value_node) -> List[Literal]: m = "Value is not of Node Kind {}".format( stringify_node(self.shape.sg.graph, self.nodekind_rule)) return [Literal(m)]