-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexceptions.py
52 lines (30 loc) · 1.89 KB
/
exceptions.py
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
import os
def argument_exceptions(source_path: str, destination_path: str):
if not os.path.exists(source_path):
raise FileNotFoundError("Path to the source file is invalid.")
if not os.path.exists(destination_path):
raise FileNotFoundError("Path to the destination directory is invalid.")
if os.path.isfile(destination_path):
raise InvalidDirectoryPathException
if os.path.isdir(source_path):
raise InvalidFilePathException
class ChasseException(Exception):
"""Base exception of the application."""
class InvalidDirectoryPathException(ChasseException):
"""Thrown if the corresponding argument is a file instead of a directory."""
class InvalidFilePathException(ChasseException):
"""Thrown if the corresponding argument is a directory instead of a file."""
class NoSpecifiedParentsException(ChasseException):
"""Thrown if the child document has no mentions of any parent document."""
class ParentAsDirectoryException(ChasseException):
"""Thrown if the child document bears mention of a parent document that is actualy a directory."""
class ParentFilesNotFoundException(ChasseException):
"""Thrown if the parent path does not have all files mentioned by a source file."""
class ComponentCountMismatchException(ChasseException):
"""Thrown if the count of the parsed components don't match the count of the required components."""
class ParentPathNotSpecifiedException(ChasseException):
"""Thrown if the -p or --parent-path flag has been used without specifying the path."""
class ResultantFileNameNotSpecifiedException(ChasseException):
"""Thrown if the -n or --name flag has been used without specifying the resultant file name."""
class MultiLineCommentBeforeParentDeclarationException(ChasseException):
"""Thrown if we have a multi-line HTML comment (that spans across multiple lines) before the parent file definitions."""