|
1
|
|
|
#!/usr/bin/env python |
|
2
|
|
|
# -*- coding: utf-8 -*- |
|
3
|
|
|
|
|
4
|
|
|
""" |
|
5
|
|
|
cookiecutter.exceptions |
|
6
|
|
|
----------------------- |
|
7
|
|
|
|
|
8
|
|
|
All exceptions used in the Cookiecutter code base are defined here. |
|
9
|
|
|
""" |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class CookiecutterException(Exception): |
|
13
|
|
|
""" |
|
14
|
|
|
Base exception class. All Cookiecutter-specific exceptions should subclass |
|
15
|
|
|
this class. |
|
16
|
|
|
""" |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
class NonTemplatedInputDirException(CookiecutterException): |
|
20
|
|
|
""" |
|
21
|
|
|
Raised when a project's input dir is not templated. |
|
22
|
|
|
The name of the input directory should always contain a string that is |
|
23
|
|
|
rendered to something else, so that input_dir != output_dir. |
|
24
|
|
|
""" |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
class UnknownTemplateDirException(CookiecutterException): |
|
28
|
|
|
""" |
|
29
|
|
|
Raised when Cookiecutter cannot determine which directory is the project |
|
30
|
|
|
template, e.g. more than one dir appears to be a template dir. |
|
31
|
|
|
""" |
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
class MissingProjectDir(CookiecutterException): |
|
35
|
|
|
""" |
|
36
|
|
|
Raised during cleanup when remove_repo() can't find a generated project |
|
37
|
|
|
directory inside of a repo. |
|
38
|
|
|
""" |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
class ConfigDoesNotExistException(CookiecutterException): |
|
42
|
|
|
""" |
|
43
|
|
|
Raised when get_config() is passed a path to a config file, but no file |
|
44
|
|
|
is found at that path. |
|
45
|
|
|
""" |
|
46
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
class InvalidConfiguration(CookiecutterException): |
|
49
|
|
|
""" |
|
50
|
|
|
Raised if the global configuration file is not valid YAML or is |
|
51
|
|
|
badly contructed. |
|
52
|
|
|
""" |
|
53
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
class UnknownRepoType(CookiecutterException): |
|
56
|
|
|
""" |
|
57
|
|
|
Raised if a repo's type cannot be determined. |
|
58
|
|
|
""" |
|
59
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
class VCSNotInstalled(CookiecutterException): |
|
62
|
|
|
""" |
|
63
|
|
|
Raised if the version control system (git or hg) is not installed. |
|
64
|
|
|
""" |
|
65
|
|
|
|
|
66
|
|
|
|
|
67
|
|
|
class ContextDecodingException(CookiecutterException): |
|
68
|
|
|
""" |
|
69
|
|
|
Raised when a project's JSON context file can not be decoded. |
|
70
|
|
|
""" |
|
71
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
class OutputDirExistsException(CookiecutterException): |
|
74
|
|
|
""" |
|
75
|
|
|
Raised when the output directory of the project exists already. |
|
76
|
|
|
""" |
|
77
|
|
|
|
|
78
|
|
|
|
|
79
|
|
|
class InvalidModeException(CookiecutterException): |
|
80
|
|
|
""" |
|
81
|
|
|
Raised when cookiecutter is called with both `no_input==True` and |
|
82
|
|
|
`replay==True` at the same time. |
|
83
|
|
|
""" |
|
84
|
|
|
|
|
85
|
|
|
|
|
86
|
|
|
class FailedHookException(CookiecutterException): |
|
87
|
|
|
""" |
|
88
|
|
|
Raised when a hook script fails |
|
89
|
|
|
""" |
|
90
|
|
|
|
|
91
|
|
|
|
|
92
|
|
|
class UndefinedVariableInTemplate(CookiecutterException): |
|
93
|
|
|
"""Raised when a template uses a variable which is not defined in the |
|
94
|
|
|
context. |
|
95
|
|
|
""" |
|
96
|
|
|
def __init__(self, message, error, context): |
|
97
|
|
|
self.message = message |
|
98
|
|
|
self.error = error |
|
99
|
|
|
self.context = context |
|
100
|
|
|
|
|
101
|
|
|
def __str__(self): |
|
102
|
|
|
return ( |
|
103
|
|
|
"{self.message}. " |
|
104
|
|
|
"Error message: {self.error.message}. " |
|
105
|
|
|
"Context: {self.context}" |
|
106
|
|
|
).format(**locals()) |
|
107
|
|
|
|
|
108
|
|
|
|
|
109
|
|
|
class UnknownExtension(CookiecutterException): |
|
110
|
|
|
"""Raised when an environment is unable to import a required extension.""" |
|
111
|
|
|
|