ansible/errors: PEP8 compliancy (#24693)

- Make PEP8 compliant
This commit is contained in:
Dag Wieers 2017-05-18 09:34:57 +02:00 committed by John R Barker
parent 7a5e46c732
commit ac27c54c2e
2 changed files with 28 additions and 13 deletions

View file

@ -19,13 +19,15 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
from ansible.errors.yaml_strings import ( YAML_POSITION_DETAILS, from ansible.errors.yaml_strings import (
YAML_COMMON_UNQUOTED_VARIABLE_ERROR,
YAML_COMMON_DICT_ERROR, YAML_COMMON_DICT_ERROR,
YAML_COMMON_UNQUOTED_COLON_ERROR, YAML_COMMON_LEADING_TAB_ERROR,
YAML_COMMON_PARTIALLY_QUOTED_LINE_ERROR, YAML_COMMON_PARTIALLY_QUOTED_LINE_ERROR,
YAML_COMMON_UNBALANCED_QUOTES_ERROR, YAML_COMMON_UNBALANCED_QUOTES_ERROR,
YAML_COMMON_LEADING_TAB_ERROR) YAML_COMMON_UNQUOTED_COLON_ERROR,
YAML_COMMON_UNQUOTED_VARIABLE_ERROR,
YAML_POSITION_DETAILS,
)
from ansible.module_utils._text import to_native, to_text from ansible.module_utils._text import to_native, to_text
@ -107,9 +109,9 @@ class AnsibleError(Exception):
target_line = to_text(target_line) target_line = to_text(target_line)
prev_line = to_text(prev_line) prev_line = to_text(prev_line)
if target_line: if target_line:
stripped_line = target_line.replace(" ","") stripped_line = target_line.replace(" ", "")
arrow_line = (" " * (col_number-1)) + "^ here" arrow_line = (" " * (col_number - 1)) + "^ here"
#header_line = ("=" * 73) # header_line = ("=" * 73)
error_message += "\nThe offending line appears to be:\n\n%s\n%s\n%s\n" % (prev_line.rstrip(), target_line.rstrip(), arrow_line) error_message += "\nThe offending line appears to be:\n\n%s\n%s\n%s\n" % (prev_line.rstrip(), target_line.rstrip(), arrow_line)
# TODO: There may be cases where there is a valid tab in a line that has other errors. # TODO: There may be cases where there is a valid tab in a line that has other errors.
@ -143,8 +145,8 @@ class AnsibleError(Exception):
match = True match = True
if (len(middle) > 0 and if (len(middle) > 0 and
middle[0] in [ '"', "'" ] and middle[0] in ['"', "'"] and
middle[-1] in [ '"', "'" ] and middle[-1] in ['"', "'"] and
target_line.count("'") > 2 or target_line.count("'") > 2 or
target_line.count('"') > 2): target_line.count('"') > 2):
unbalanced = True unbalanced = True
@ -161,53 +163,67 @@ class AnsibleError(Exception):
return error_message return error_message
class AnsibleOptionsError(AnsibleError): class AnsibleOptionsError(AnsibleError):
''' bad or incomplete options passed ''' ''' bad or incomplete options passed '''
pass pass
class AnsibleParserError(AnsibleError): class AnsibleParserError(AnsibleError):
''' something was detected early that is wrong about a playbook or data file ''' ''' something was detected early that is wrong about a playbook or data file '''
pass pass
class AnsibleInternalError(AnsibleError): class AnsibleInternalError(AnsibleError):
''' internal safeguards tripped, something happened in the code that should never happen ''' ''' internal safeguards tripped, something happened in the code that should never happen '''
pass pass
class AnsibleRuntimeError(AnsibleError): class AnsibleRuntimeError(AnsibleError):
''' ansible had a problem while running a playbook ''' ''' ansible had a problem while running a playbook '''
pass pass
class AnsibleModuleError(AnsibleRuntimeError): class AnsibleModuleError(AnsibleRuntimeError):
''' a module failed somehow ''' ''' a module failed somehow '''
pass pass
class AnsibleConnectionFailure(AnsibleRuntimeError): class AnsibleConnectionFailure(AnsibleRuntimeError):
''' the transport / connection_plugin had a fatal error ''' ''' the transport / connection_plugin had a fatal error '''
pass pass
class AnsibleFilterError(AnsibleRuntimeError): class AnsibleFilterError(AnsibleRuntimeError):
''' a templating failure ''' ''' a templating failure '''
pass pass
class AnsibleLookupError(AnsibleRuntimeError): class AnsibleLookupError(AnsibleRuntimeError):
''' a lookup failure ''' ''' a lookup failure '''
pass pass
class AnsibleCallbackError(AnsibleRuntimeError): class AnsibleCallbackError(AnsibleRuntimeError):
''' a callback failure ''' ''' a callback failure '''
pass pass
class AnsibleUndefinedVariable(AnsibleRuntimeError): class AnsibleUndefinedVariable(AnsibleRuntimeError):
''' a templating failure ''' ''' a templating failure '''
pass pass
class AnsibleFileNotFound(AnsibleRuntimeError): class AnsibleFileNotFound(AnsibleRuntimeError):
''' a file missing failure ''' ''' a file missing failure '''
pass pass
class AnsibleActionSkip(AnsibleRuntimeError): class AnsibleActionSkip(AnsibleRuntimeError):
''' an action runtime skip''' ''' an action runtime skip'''
pass pass
class AnsibleActionFail(AnsibleRuntimeError): class AnsibleActionFail(AnsibleRuntimeError):
''' an action runtime failure''' ''' an action runtime failure'''
pass pass

View file

@ -18,7 +18,6 @@ lib/ansible/compat/__init__.py
lib/ansible/compat/selectors/__init__.py lib/ansible/compat/selectors/__init__.py
lib/ansible/compat/tests/__init__.py lib/ansible/compat/tests/__init__.py
lib/ansible/constants.py lib/ansible/constants.py
lib/ansible/errors/__init__.py
lib/ansible/executor/__init__.py lib/ansible/executor/__init__.py
lib/ansible/executor/action_write_locks.py lib/ansible/executor/action_write_locks.py
lib/ansible/executor/module_common.py lib/ansible/executor/module_common.py