|
1
|
|
|
# -*- coding: utf-8 -*- |
|
2
|
1 |
|
"""Exception Classes |
|
3
|
|
|
""" |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
1 |
|
class BaseError(Exception): |
|
7
|
|
|
"""Base error |
|
8
|
|
|
""" |
|
9
|
|
|
|
|
10
|
1 |
|
pass |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
1 |
|
class ChangeFileNameError(BaseError): |
|
14
|
|
|
"""rename::ChangeFileName module error |
|
15
|
|
|
""" |
|
16
|
|
|
|
|
17
|
1 |
|
def __init__(self, error_class, message): |
|
18
|
1 |
|
self.error_class = error_class |
|
19
|
1 |
|
self.message = message |
|
20
|
|
|
|
|
21
|
1 |
|
def __str__(self): |
|
22
|
1 |
|
return "{error_class}: {message}".format( |
|
23
|
|
|
error_class=self.error_class, message=self.message |
|
24
|
|
|
) |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
1 |
|
class MakePDFError(BaseError): |
|
28
|
|
|
"""convert::MakePDF module error |
|
29
|
|
|
""" |
|
30
|
|
|
|
|
31
|
1 |
|
def __init__(self, error_class, message): |
|
32
|
1 |
|
self.error_class = error_class |
|
33
|
1 |
|
self.message = message |
|
34
|
|
|
|
|
35
|
1 |
|
def __str__(self): |
|
36
|
1 |
|
return "{error_class}: {message}".format( |
|
37
|
|
|
error_class=self.error_class, message=self.message |
|
38
|
|
|
) |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
1 |
|
class MakeZIPError(BaseError): |
|
42
|
|
|
"""archive::MakeZip module error |
|
43
|
|
|
""" |
|
44
|
|
|
|
|
45
|
1 |
|
def __init__(self, error_class, message): |
|
46
|
1 |
|
self.error_class = error_class |
|
47
|
1 |
|
self.message = message |
|
48
|
|
|
|
|
49
|
1 |
|
def __str__(self): |
|
50
|
1 |
|
return "{error_class}: {message}".format( |
|
51
|
|
|
error_class=self.error_class, message=self.message |
|
52
|
|
|
) |
|
53
|
|
|
|
|
54
|
|
|
|
|
55
|
1 |
|
class ZipFileExistError(MakeZIPError): |
|
56
|
|
|
"""Zip file already exist error |
|
57
|
|
|
""" |
|
58
|
|
|
|
|
59
|
1 |
|
def __init__(self): |
|
60
|
1 |
|
super().__init__( |
|
61
|
|
|
"ZipFileExistError", |
|
62
|
|
|
"Already Zipfile you decide name exist. " |
|
63
|
|
|
"If overwrite, choose 'overwrite' parameter.", |
|
64
|
|
|
) |
|
65
|
|
|
|
|
66
|
|
|
|
|
67
|
1 |
|
class InvalidDigitsFormatError(ChangeFileNameError): |
|
68
|
|
|
"""Invalid serial number digit value error |
|
69
|
|
|
""" |
|
70
|
|
|
|
|
71
|
1 |
|
def __init__(self): |
|
72
|
1 |
|
super().__init__( |
|
73
|
|
|
"InvalidDigitsFormatError", |
|
74
|
|
|
"Invalid serial number digit value. " |
|
75
|
|
|
"If you want to use multiple digits, " |
|
76
|
|
|
"please divide into comma separator", |
|
77
|
|
|
) |
|
78
|
|
|
|
|
79
|
|
|
|
|
80
|
1 |
|
class InvalidExtensionTypeError(ChangeFileNameError): |
|
81
|
|
|
"""Invalid Extension Type error |
|
82
|
|
|
""" |
|
83
|
|
|
|
|
84
|
1 |
|
def __init__(self): |
|
85
|
1 |
|
super().__init__( |
|
86
|
|
|
"InvalidExtensionTypeError", |
|
87
|
|
|
"Invalid Extension Type. " "Expected string or bytes-like object", |
|
88
|
|
|
) |
|
89
|
|
|
|
|
90
|
|
|
|
|
91
|
1 |
|
class InvalidPathTypeError(ChangeFileNameError): |
|
92
|
|
|
"""Invalid Path string Type error |
|
93
|
|
|
""" |
|
94
|
|
|
|
|
95
|
1 |
|
def __init__(self): |
|
96
|
1 |
|
super().__init__( |
|
97
|
|
|
"InvalidPathTypeError", |
|
98
|
|
|
"Invalid Path string Type. " |
|
99
|
|
|
"Expected string, bytes-like, os.Path-like object", |
|
100
|
|
|
) |
|
101
|
|
|
|
|
102
|
|
|
|
|
103
|
1 |
|
class TargetSrcFileNotFoundError(ChangeFileNameError): |
|
104
|
|
|
"""Source directory you choose is no Target file error |
|
105
|
|
|
""" |
|
106
|
|
|
|
|
107
|
1 |
|
def __init__(self): |
|
108
|
1 |
|
super().__init__( |
|
109
|
|
|
"TargetSrcFileNotFoundError", |
|
110
|
|
|
"Source directory you choose is no Target file.", |
|
111
|
|
|
) |
|
112
|
|
|
|
|
113
|
|
|
|
|
114
|
1 |
|
class InvalidNumberParameterTypeError(ChangeFileNameError): |
|
115
|
|
|
"""To create new file name, must be used 'Integer' error |
|
116
|
|
|
""" |
|
117
|
|
|
|
|
118
|
1 |
|
def __init__(self): |
|
119
|
1 |
|
super().__init__( |
|
120
|
|
|
"InvalidNumberParameterTypeError", |
|
121
|
|
|
"To create new file name, must be used 'Integer'.", |
|
122
|
|
|
) |
|
123
|
|
|
|
|
124
|
|
|
|
|
125
|
1 |
|
class InvalidImageParameterTypeError(ChangeFileNameError): |
|
126
|
|
|
"""InvalidImageParameterTypeError |
|
127
|
|
|
""" |
|
128
|
|
|
|
|
129
|
1 |
|
def __init__(self): |
|
130
|
1 |
|
super().__init__( |
|
131
|
|
|
"InvalidImageParameterTypeError", |
|
132
|
|
|
"To check image file, " "must be 'Image file' such as jpeg, png, or gif.", |
|
133
|
|
|
) |
|
134
|
|
|
|
|
135
|
|
|
|
|
136
|
1 |
|
class InvalidImageFileFormatError(MakePDFError): |
|
137
|
|
|
"""InvalidImageFileFormatError |
|
138
|
|
|
""" |
|
139
|
|
|
|
|
140
|
1 |
|
def __init__(self): |
|
141
|
1 |
|
super().__init__( |
|
142
|
|
|
"InvalidImageFileFormatError", |
|
143
|
|
|
"Not supported file format." "Supported 'jpg', 'png', 'gif'", |
|
144
|
|
|
) |
|
145
|
|
|
|
|
146
|
|
|
|
|
147
|
1 |
|
class ChangeFileNameOSError(ChangeFileNameError): |
|
148
|
|
|
"""ChangeFileNameOSError |
|
149
|
|
|
""" |
|
150
|
|
|
|
|
151
|
1 |
|
def __init__(self): |
|
152
|
1 |
|
super().__init__( |
|
153
|
|
|
"ChangeFileNameOSError", "OSError was occurred. Reading more message above." |
|
154
|
|
|
) |
|
155
|
|
|
|