mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2024-11-14 17:40:24 -08:00
56c6773c6b
Updates colorama to 0.4.6 Adds confuse version 1.7.0 Updates jellyfish to 0.9.0 Adds mediafile 0.10.1 Updates munkres to 1.1.4 Updates musicbrainzngs to 0.7.1 Updates mutagen to 1.46.0 Updates pyyaml to 6.0 Updates unidecode to 1.3.6
57 lines
1.6 KiB
Python
57 lines
1.6 KiB
Python
from __future__ import division, absolute_import, print_function
|
|
|
|
import yaml
|
|
|
|
__all__ = [
|
|
'ConfigError', 'NotFoundError', 'ConfigValueError', 'ConfigTypeError',
|
|
'ConfigTemplateError', 'ConfigReadError']
|
|
|
|
YAML_TAB_PROBLEM = "found character '\\t' that cannot start any token"
|
|
|
|
# Exceptions.
|
|
|
|
|
|
class ConfigError(Exception):
|
|
"""Base class for exceptions raised when querying a configuration.
|
|
"""
|
|
|
|
|
|
class NotFoundError(ConfigError):
|
|
"""A requested value could not be found in the configuration trees.
|
|
"""
|
|
|
|
|
|
class ConfigValueError(ConfigError):
|
|
"""The value in the configuration is illegal."""
|
|
|
|
|
|
class ConfigTypeError(ConfigValueError):
|
|
"""The value in the configuration did not match the expected type.
|
|
"""
|
|
|
|
|
|
class ConfigTemplateError(ConfigError):
|
|
"""Base class for exceptions raised because of an invalid template.
|
|
"""
|
|
|
|
|
|
class ConfigReadError(ConfigError):
|
|
"""A configuration source could not be read."""
|
|
def __init__(self, name, reason=None):
|
|
self.name = name
|
|
self.reason = reason
|
|
|
|
message = u'{0} could not be read'.format(name)
|
|
if (isinstance(reason, yaml.scanner.ScannerError)
|
|
and reason.problem == YAML_TAB_PROBLEM):
|
|
# Special-case error message for tab indentation in YAML markup.
|
|
message += u': found tab character at line {0}, column {1}'.format(
|
|
reason.problem_mark.line + 1,
|
|
reason.problem_mark.column + 1,
|
|
)
|
|
elif reason:
|
|
# Generic error message uses exception's message.
|
|
message += u': {0}'.format(reason)
|
|
|
|
super(ConfigReadError, self).__init__(message)
|