Completed
Push — master ( 24da64...15c423 )
by Gonzalo
65:23
created

EnvironmentFileExtensionNotValid   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 5
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 4 1
1
# -*- coding: utf-8 -*-
2
# Copyright (C) 2012 Anaconda, Inc
3
# SPDX-License-Identifier: BSD-3-Clause
4
from conda import CondaError
5
6
7
class CondaEnvException(CondaError):
8
    def __init__(self, message, *args, **kwargs):
9
        msg = "%s" % message
10
        super(CondaEnvException, self).__init__(msg, *args, **kwargs)
11
12
13
class EnvironmentFileNotFound(CondaEnvException):
14
    def __init__(self, filename, *args, **kwargs):
15
        msg = "'{}' file not found".format(filename)
16
        self.filename = filename
17
        super(EnvironmentFileNotFound, self).__init__(msg, *args, **kwargs)
18
19
20
class EnvironmentFileExtensionNotValid(CondaEnvException):
21
    def __init__(self, filename, *args, **kwargs):
22
        msg = "'{}' file extension must be one of '.txt', '.yaml' or '.yml'".format(filename)
23
        self.filename = filename
24
        super(EnvironmentFileExtensionNotValid, self).__init__(msg, *args, **kwargs)
25
26
27
class NoBinstar(CondaError):
28
    def __init__(self):
29
        msg = 'The anaconda-client cli must be installed to perform this action'
30
        super(NoBinstar, self).__init__(msg)
31
32
33
class AlreadyExist(CondaError):
34
    def __init__(self):
35
        msg = 'The environment path already exists'
36
        super(AlreadyExist, self).__init__(msg)
37
38
39
class EnvironmentAlreadyInNotebook(CondaError):
40
    def __init__(self, notebook, *args, **kwargs):
41
        msg = "The notebook {} already has an environment"
42
        super(EnvironmentAlreadyInNotebook, self).__init__(msg, *args, **kwargs)
43
44
45
class EnvironmentFileDoesNotExist(CondaError):
46
    def __init__(self, handle, *args, **kwargs):
47
        self.handle = handle
48
        msg = "{} does not have an environment definition".format(handle)
49
        super(EnvironmentFileDoesNotExist, self).__init__(msg, *args, **kwargs)
50
51
52
class EnvironmentFileNotDownloaded(CondaError):
53
    def __init__(self, username, packagename, *args, **kwargs):
54
        msg = '{}/{} file not downloaded'.format(username, packagename)
55
        self.username = username
56
        self.packagename = packagename
57
        super(EnvironmentFileNotDownloaded, self).__init__(msg, *args, **kwargs)
58
59
60
class SpecNotFound(CondaError):
61
    def __init__(self, msg, *args, **kwargs):
62
        super(SpecNotFound, self).__init__(msg, *args, **kwargs)
63
64
65
class InvalidLoader(Exception):
66
    def __init__(self, name):
67
        msg = 'Unable to load installer for {}'.format(name)
68
        super(InvalidLoader, self).__init__(msg)
69
70
71
class NBFormatNotInstalled(CondaError):
72
    def __init__(self):
73
        msg = """nbformat is not installed. Install it with:
74
        conda install nbformat
75
        """
76
        super(NBFormatNotInstalled, self).__init__(msg)
77