Completed
Pull Request — master (#694)
by Eric
02:14
created

InvalidType   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 2 1
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
97
    def __init__(self, message, error, context):
98
        self.message = message
99
        self.error = error
100
        self.context = context
101
102
    def __str__(self):
103
        return (
104
            "{self.message}. "
105
            "Error message: {self.error.message}. "
106
            "Context: {self.context}"
107
        ).format(**locals())
108
109
110
class UnknownExtension(CookiecutterException):
111
    """Raised when an environment is unable to import a required extension."""
112
113
114
class RepositoryNotFound(CookiecutterException):
115
    """
116
    Raised when the specified cookiecutter repository doesn't exist.
117
    """
118
119
120
class InvalidType(CookiecutterException):
121
    """
122
    Raised when a specified object is not an instance of a required type
123
    """
124
125
    def __init__(self, type):
126
        self.message = 'The object must be of type: ' + type
127
128
129
class UnknownSerializerType(CookiecutterException):
130
    """
131
    Raised when the specified serializer is not known by the serialization
132
    facade.
133
    """
134
135
    def __init__(self, type):
136
        self.message = 'Unknown serializer type: ' + type
137
138
139
class BadSerializedStringFormat(CookiecutterException):
140
    """
141
    Raised when a serialized string is not well formed
142
    """
143
144
    def __init__(self, message):
145
        self.message = message
146
147
148
class InvalidSerializerType(CookiecutterException):
149
    """
150
    Raised when the specified serializer type is not allowed
151
    facade.
152
    """
153