Completed
Pull Request — master (#885)
by
unknown
01:21
created

OutputFileExistsException.__init__()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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