|
1
|
|
|
|
|
2
|
|
|
|
|
3
|
|
|
class FileActionsException(Exception): |
|
4
|
|
|
''' |
|
5
|
|
|
Base class for file-actions exceptions |
|
6
|
|
|
''' |
|
7
|
|
|
code = None |
|
8
|
|
|
template = 'Unhandled error.' |
|
9
|
|
|
|
|
10
|
|
|
def __init__(self, message=None, path=None): |
|
11
|
|
|
self.path = path |
|
12
|
|
|
message = self.template.format(self) if message is None else message |
|
13
|
|
|
super(FileActionsException, self).__init__(message) |
|
14
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
class InvalidDirnameError(FileActionsException): |
|
17
|
|
|
''' |
|
18
|
|
|
Exception raised when a clipboard item is not valid. |
|
19
|
|
|
|
|
20
|
|
|
:property name: name which raised this Exception |
|
21
|
|
|
''' |
|
22
|
|
|
code = 'invalid-dirname' |
|
23
|
|
|
template = 'Clipboard item {0.name!r} is not valid.' |
|
24
|
|
|
|
|
25
|
|
|
def __init__(self, message=None, path=None, name=None): |
|
26
|
|
|
self.name = name |
|
27
|
|
|
super(InvalidDirnameError, self).__init__(message, path) |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
class ClipboardException(FileActionsException): |
|
31
|
|
|
''' |
|
32
|
|
|
Base class for clipboard exceptions. |
|
33
|
|
|
''' |
|
34
|
|
|
pass |
|
35
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
class InvalidClipboardItemError(ClipboardException): |
|
38
|
|
|
''' |
|
39
|
|
|
Exception raised when a clipboard item is not valid. |
|
40
|
|
|
|
|
41
|
|
|
:property path: item path which raised this Exception |
|
42
|
|
|
''' |
|
43
|
|
|
code = 'invalid-clipboard-item' |
|
44
|
|
|
template = 'Clipboard item {0.item!r} is not valid.' |
|
45
|
|
|
|
|
46
|
|
|
def __init__(self, message=None, path=None, item=None): |
|
47
|
|
|
self.item = item |
|
48
|
|
|
super(InvalidClipboardItemError, self).__init__(message, path) |
|
49
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
class MissingClipboardItemError(InvalidClipboardItemError): |
|
52
|
|
|
''' |
|
53
|
|
|
Exception raised when a clipboard item is not valid. |
|
54
|
|
|
|
|
55
|
|
|
:property path: item path which raised this Exception |
|
56
|
|
|
''' |
|
57
|
|
|
code = 'missing-clipboard-item' |
|
58
|
|
|
template = 'Clipboard item {0.item!r} not found.' |
|
59
|
|
|
|
|
60
|
|
|
def __init__(self, message=None, path=None, item=None): |
|
61
|
|
|
self.item = item |
|
62
|
|
|
super(InvalidClipboardItemError, self).__init__(message, path) |
|
63
|
|
|
|
|
64
|
|
|
|
|
65
|
|
|
class InvalidClipboardModeError(ClipboardException): |
|
66
|
|
|
''' |
|
67
|
|
|
Exception raised when a clipboard mode is not valid. |
|
68
|
|
|
|
|
69
|
|
|
:property mode: mode which raised this Exception |
|
70
|
|
|
''' |
|
71
|
|
|
code = 'invalid-clipboard-mode' |
|
72
|
|
|
template = 'Clipboard mode {0.path!r} is not valid.' |
|
73
|
|
|
|
|
74
|
|
|
def __init__(self, message=None, path=None, mode=None): |
|
75
|
|
|
self.mode = mode |
|
76
|
|
|
super(InvalidClipboardModeError, self).__init__(message, path) |
|
77
|
|
|
|
|
78
|
|
|
|
|
79
|
|
|
class InvalidClipboardSizeError(ClipboardException): |
|
80
|
|
|
''' |
|
81
|
|
|
Exception raised when a clipboard size exceeds cookie limit. |
|
82
|
|
|
|
|
83
|
|
|
:property max_cookies: maximum allowed size |
|
84
|
|
|
''' |
|
85
|
|
|
code = 'invalid-clipboard-size' |
|
86
|
|
|
template = 'Clipboard has too many items.' |
|
87
|
|
|
|
|
88
|
|
|
def __init__(self, message=None, path=None, max_cookies=0): |
|
89
|
|
|
self.max_cookies = max_cookies |
|
90
|
|
|
super(InvalidClipboardSizeError, self).__init__(message, path) |
|
91
|
|
|
|