comparison env/lib/python3.7/site-packages/rdflib/exceptions.py @ 5:9b1c78e6ba9c draft default tip

"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
author shellac
date Mon, 01 Jun 2020 08:59:25 -0400
parents 79f47841a781
children
comparison
equal deleted inserted replaced
4:79f47841a781 5:9b1c78e6ba9c
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 def __init__(self, msg=None):
13 Exception.__init__(self, msg)
14 self.msg = msg
15
16
17 class TypeCheckError(Error):
18 """Parts of assertions are subject to type checks."""
19
20 def __init__(self, node):
21 Error.__init__(self, node)
22 self.type = type(node)
23 self.node = node
24
25
26 class SubjectTypeError(TypeCheckError):
27 """Subject of an assertion must be an instance of URIRef."""
28 def __init__(self, node):
29 TypeCheckError.__init__(self, node)
30 self.msg = "Subject must be instance of URIRef or BNode: %s(%s)" \
31 % (self.node, self.type)
32
33
34 class PredicateTypeError(TypeCheckError):
35 """Predicate of an assertion must be an instance of URIRef."""
36 def __init__(self, node):
37 TypeCheckError.__init__(self, node)
38 self.msg = "Predicate must be a URIRef instance: %s(%s)" \
39 % (self.node, self.type)
40
41
42 class ObjectTypeError(TypeCheckError):
43 """Object of an assertion must be an instance of URIRef, Literal,
44 or BNode."""
45 def __init__(self, node):
46 TypeCheckError.__init__(self, node)
47 self.msg = "\
48 Object must be instance of URIRef, Literal, or BNode: %s(%s)" % \
49 (self.node, self.type)
50
51
52 class ContextTypeError(TypeCheckError):
53 """Context of an assertion must be an instance of URIRef."""
54 def __init__(self, node):
55 TypeCheckError.__init__(self, node)
56 self.msg = "Context must be instance of URIRef or BNode: %s(%s)" \
57 % (self.node, self.type)
58
59
60 class ParserError(Error):
61 """RDF Parser error."""
62 def __init__(self, msg):
63 Error.__init__(self, msg)
64 self.msg = msg
65
66 def __str__(self):
67 return self.msg
68
69
70 class UniquenessError(Error):
71 """A uniqueness assumption was made in the context, and that is not true"""
72 def __init__(self, values):
73 Error.__init__(self, "\
74 Uniqueness assumption is not fulfilled. Multiple values are: %s" % values)