File: Exceptions.py

package info (click to toggle)
pyxdg 0.28-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 784 kB
  • sloc: python: 4,584; makefile: 135; sh: 14
file content (84 lines) | stat: -rw-r--r-- 2,494 bytes parent folder | download | duplicates (3)
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
80
81
82
83
84
"""
Exception Classes for the xdg package
"""

debug = False

class Error(Exception):
    """Base class for exceptions defined here."""
    def __init__(self, msg):
        self.msg = msg
        Exception.__init__(self, msg)
    def __str__(self):
        return self.msg

class ValidationError(Error):
    """Raised when a file fails to validate.
    
    The filename is the .file attribute.
    """
    def __init__(self, msg, file):
        self.msg = msg
        self.file = file
        Error.__init__(self, "ValidationError in file '%s': %s " % (file, msg))

class ParsingError(Error):
    """Raised when a file cannot be parsed.
    
    The filename is the .file attribute.
    """
    def __init__(self, msg, file):
        self.msg = msg
        self.file = file
        Error.__init__(self, "ParsingError in file '%s', %s" % (file, msg))

class NoKeyError(Error):
    """Raised when trying to access a nonexistant key in an INI-style file.
    
    Attributes are .key, .group and .file.
    """
    def __init__(self, key, group, file):
        Error.__init__(self, "No key '%s' in group %s of file %s" % (key, group, file))
        self.key = key
        self.group = group
        self.file = file

class DuplicateKeyError(Error):
    """Raised when the same key occurs twice in an INI-style file.
    
    Attributes are .key, .group and .file.
    """
    def __init__(self, key, group, file):
        Error.__init__(self, "Duplicate key '%s' in group %s of file %s" % (key, group, file))
        self.key = key
        self.group = group
        self.file = file

class NoGroupError(Error):
    """Raised when trying to access a nonexistant group in an INI-style file.
    
    Attributes are .group and .file.
    """
    def __init__(self, group, file):
        Error.__init__(self, "No group: %s in file %s" % (group, file))
        self.group = group
        self.file = file

class DuplicateGroupError(Error):
    """Raised when the same key occurs twice in an INI-style file.
    
    Attributes are .group and .file.
    """
    def __init__(self, group, file):
        Error.__init__(self, "Duplicate group: %s in file %s" % (group, file))
        self.group = group
        self.file = file

class NoThemeError(Error):
    """Raised when trying to access a nonexistant icon theme.
    
    The name of the theme is the .theme attribute.
    """
    def __init__(self, theme):
        Error.__init__(self, "No such icon-theme: %s" % theme)
        self.theme = theme