Example #1
0
 def __init__(
         self, v: Union[str, URIRef, BNode, "URIorCURIE",
                        "Identifier"]) -> None:
     v = str(v) if not isinstance(v, str) else v
     if is_strict() and not self.is_valid(v):
         raise ValueError(f"{v}: is not a valid Identifier")
     TypedNode.__init__(self, v)
Example #2
0
 def logger_warning(self, warning: str, loc_str: Optional[Union[str, TypedNode, Iterator[TypedNode]]]) -> None:
     if loc_str is None or not isinstance(loc_str, (TypedNode, list)):
         self.logger.warning(warning)
     elif isinstance(loc_str, TypedNode):
         self.logger.warning(f'{warning}\n\t{TypedNode.yaml_loc(loc_str)}')
     else:
         locs = '\n\t'.join(TypedNode.loc(e) for e in loc_str)
         self.logger.warning(f'{warning}\n\t{locs}')
Example #3
0
 def raise_value_errors(error: str, loc_str: Optional[Union[str, TypedNode, Iterator[TypedNode]]]) -> None:
     if loc_str is None or not isinstance(loc_str, (TypedNode, list)):
         raise ValueError(error)
     elif isinstance(loc_str, TypedNode):
         raise ValueError(f'{TypedNode.yaml_loc(loc_str)} {error}')
     else:
         locs = '\n'.join(TypedNode.loc(e) for e in loc_str)
         raise ValueError(f'{locs} {error}')