mirror of
https://github.com/docker/compose.git
synced 2025-09-15 13:57:41 +02:00
Closes: #6890 Some remarks, - `# coding ... utf-8` statements are not needed - isdigit on strings instead of a try-catch. - Default opening mode is read, so we can do `open()` without the `'r'` everywhere - Removed inheritinng from `object` class, it isn't necessary in python3. - `super(ClassName, self)` can now be replaced with `super()` - Use of itertools and `chain` on a couple places dealing with sets. - Used the operator module instead of lambdas when warranted `itemgetter(0)` instead of `lambda x: x[0]` `attrgetter('name')` instead of `lambda x: x.name` - `sorted` returns a list, so no need to use `list(sorted(...))` - Removed `dict()` using dictionary comprehensions whenever possible - Attempted to remove python3.2 support Signed-off-by: alexrecuenco <alejandrogonzalezrecuenco@gmail.com>
56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
VERSION_EXPLANATION = (
|
|
'You might be seeing this error because you\'re using the wrong Compose file version. '
|
|
'Either specify a supported version (e.g "2.2" or "3.3") and place '
|
|
'your service definitions under the `services` key, or omit the `version` key '
|
|
'and place your service definitions at the root of the file to use '
|
|
'version 1.\nFor more on the Compose file format versions, see '
|
|
'https://docs.docker.com/compose/compose-file/')
|
|
|
|
|
|
class ConfigurationError(Exception):
|
|
def __init__(self, msg):
|
|
self.msg = msg
|
|
|
|
def __str__(self):
|
|
return self.msg
|
|
|
|
|
|
class EnvFileNotFound(ConfigurationError):
|
|
pass
|
|
|
|
|
|
class DependencyError(ConfigurationError):
|
|
pass
|
|
|
|
|
|
class CircularReference(ConfigurationError):
|
|
def __init__(self, trail):
|
|
self.trail = trail
|
|
|
|
@property
|
|
def msg(self):
|
|
lines = [
|
|
"{} in {}".format(service_name, filename)
|
|
for (filename, service_name) in self.trail
|
|
]
|
|
return "Circular reference:\n {}".format("\n extends ".join(lines))
|
|
|
|
|
|
class ComposeFileNotFound(ConfigurationError):
|
|
def __init__(self, supported_filenames):
|
|
super().__init__("""
|
|
Can't find a suitable configuration file in this directory or any
|
|
parent. Are you in the right directory?
|
|
|
|
Supported filenames: %s
|
|
""" % ", ".join(supported_filenames))
|
|
|
|
|
|
class DuplicateOverrideFileFound(ConfigurationError):
|
|
def __init__(self, override_filenames):
|
|
self.override_filenames = override_filenames
|
|
super().__init__(
|
|
"Multiple override files found: {}. You may only use a single "
|
|
"override file.".format(", ".join(override_filenames))
|
|
)
|