Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/rdflib/exceptions.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
| author | shellac |
|---|---|
| date | Mon, 22 Mar 2021 18:12:50 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:4f3585e2f14b |
|---|---|
| 1 """ | |
| 2 TODO: | |
| 3 """ | |
| 4 | |
| 5 __all__ = ['Error', 'TypeCheckError', 'SubjectTypeError', | |
| 6 'PredicateTypeError', 'ObjectTypeError', 'ContextTypeError', | |
| 7 'ParserError'] | |
| 8 | |
| 9 | |
| 10 class Error(Exception): | |
| 11 """Base class for rdflib exceptions.""" | |
| 12 | |
| 13 def __init__(self, msg=None): | |
| 14 Exception.__init__(self, msg) | |
| 15 self.msg = msg | |
| 16 | |
| 17 | |
| 18 class TypeCheckError(Error): | |
| 19 """Parts of assertions are subject to type checks.""" | |
| 20 | |
| 21 def __init__(self, node): | |
| 22 Error.__init__(self, node) | |
| 23 self.type = type(node) | |
| 24 self.node = node | |
| 25 | |
| 26 | |
| 27 class SubjectTypeError(TypeCheckError): | |
| 28 """Subject of an assertion must be an instance of URIRef.""" | |
| 29 | |
| 30 def __init__(self, node): | |
| 31 TypeCheckError.__init__(self, node) | |
| 32 self.msg = "Subject must be instance of URIRef or BNode: %s(%s)" \ | |
| 33 % (self.node, self.type) | |
| 34 | |
| 35 | |
| 36 class PredicateTypeError(TypeCheckError): | |
| 37 """Predicate of an assertion must be an instance of URIRef.""" | |
| 38 | |
| 39 def __init__(self, node): | |
| 40 TypeCheckError.__init__(self, node) | |
| 41 self.msg = "Predicate must be a URIRef instance: %s(%s)" \ | |
| 42 % (self.node, self.type) | |
| 43 | |
| 44 | |
| 45 class ObjectTypeError(TypeCheckError): | |
| 46 """Object of an assertion must be an instance of URIRef, Literal, | |
| 47 or BNode.""" | |
| 48 | |
| 49 def __init__(self, node): | |
| 50 TypeCheckError.__init__(self, node) | |
| 51 self.msg = "\ | |
| 52 Object must be instance of URIRef, Literal, or BNode: %s(%s)" % \ | |
| 53 (self.node, self.type) | |
| 54 | |
| 55 | |
| 56 class ContextTypeError(TypeCheckError): | |
| 57 """Context of an assertion must be an instance of URIRef.""" | |
| 58 | |
| 59 def __init__(self, node): | |
| 60 TypeCheckError.__init__(self, node) | |
| 61 self.msg = "Context must be instance of URIRef or BNode: %s(%s)" \ | |
| 62 % (self.node, self.type) | |
| 63 | |
| 64 | |
| 65 class ParserError(Error): | |
| 66 """RDF Parser error.""" | |
| 67 | |
| 68 def __init__(self, msg): | |
| 69 Error.__init__(self, msg) | |
| 70 self.msg = msg | |
| 71 | |
| 72 def __str__(self): | |
| 73 return self.msg | |
| 74 | |
| 75 | |
| 76 class UniquenessError(Error): | |
| 77 """A uniqueness assumption was made in the context, and that is not true""" | |
| 78 | |
| 79 def __init__(self, values): | |
| 80 Error.__init__(self, "\ | |
| 81 Uniqueness assumption is not fulfilled. Multiple values are: %s" % values) |
