File: exceptions.py

package info (click to toggle)
python-feedvalidator 0~svn1022-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 652 kB
  • ctags: 2,452
  • sloc: python: 9,481; makefile: 27; sh: 8
file content (79 lines) | stat: -rwxr-xr-x 2,379 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

class Error(Exception):
    """Base class for rdflib exceptions."""
    def __init__(self, msg=None):
        Exception.__init__(self, msg)
        self.msg = msg


class TypeCheckError(Error):
    """Parts of assertions are subject to type checks."""

    def __init__(self, node):
        Error.__init__(self, node)
        self.type = type(node)
        self.node = node


class SubjectTypeError(TypeCheckError):
    """Subject of an assertion must be an instance of URIRef."""
    def __init__(self, node):
        TypeCheckError.__init__(self, node)
        self.msg = "Subject must be instance of URIRef or BNode: %s(%s)" \
                       % (self.node, self.type)


class PredicateTypeError(TypeCheckError):
    """Predicate of an assertion must be an instance of URIRef."""
    def __init__(self, node):
        TypeCheckError.__init__(self, node)
        self.msg = "Predicate must be a URIRef instance: %s(%s)" \
                       % (self.node, self.type)


class ObjectTypeError(TypeCheckError):
    """Object of an assertion must be an instance of URIRef, Literal,
    or BNode."""
    def __init__(self, node):
        TypeCheckError.__init__(self, node)
        self.msg = "Object must be instance of URIRef, Literal, or BNode: %s(%s)" % \
                       (self.node, self.type)

class ContextTypeError(TypeCheckError):
    """Context of an assertion must be an instance of URIRef."""
    def __init__(self, node):
        TypeCheckError.__init__(self, node)
        self.msg = "Context must be instance of URIRef or BNode: %s(%s)" \
                       % (self.node, self.type)
        
class ParserError(Error):
    """RDF Parser error."""
    def __init__(self, msg):
        self.msg = msg
        
    def __str__(self):
        return self.msg

class SerializerDispatchNameError(Error):
    """No name set..."""
    def __init__(self, msg):
        Error.__init__(self)
        self.msg = msg

class SerializerDispatchNameClashError(Error):
    """Name clash..."""
    def __init(self, msg):
        Error.__init__(self)
        self.msg = msg

class ParserDispatchNameError(Error):
    """No name set..."""
    def __init__(self, msg):
        Error.__init__(self)
        self.msg = msg

class ParserDispatchNameClashError(Error):
    """Name clash..."""
    def __init(self, msg):
        Error.__init__(self)
        self.msg = msg