# Path: elbepack/projectmanager.py
# class ProjectManagerError(Exception):
#     def __init__(self, message):
#         Exception.__init__(self, message)
# 
# class InvalidState(ProjectManagerError):
#     def __init__(self, message):
#         ProjectManagerError.__init__(self, message)
# 
# Path: elbepack/elbexml.py
# class ValidationError(Exception):
#     def __init__(self, validation):
#         Exception.__init__(self)
#         self.validation = validation
# 
#     def __repr__(self):
#         rep = "Elbe XML Validation Error\n"
#         for v in self.validation:
#             rep += (v + '\n')
#         return rep
# 
#     def __str__(self):
#         retval = ""
#         for v in self.validation:
#             retval += (v + '\n')
#         return retval
# 
# Path: elbepack/db.py
# class ElbeDBError(Exception):
#     def __init__(self, message):
#         Exception.__init__(self, message)
# 
# class InvalidLogin(Exception):
#     def __init__(self):
#         Exception.__init__(self, "Invalid login")


from traceback import format_exc
from functools import wraps
from spyne.model.fault import Fault
from elbepack.projectmanager import ProjectManagerError, InvalidState
from elbepack.elbexml import ValidationError
from elbepack.db import ElbeDBError, InvalidLogin


class SoapElbeInvalidState(Fault):
    def __init__(self):
        Fault.__init__(self, faultcode="ElbeInvalidState",
                       faultstring="Project is Busy ! Operation Invalid")


def soap_faults(func):
    """ decorator, which wraps Exceptions to the proper
        Soap Faults, and raises these.
    """

    # Do not edit this code.  Although using *args is tempting here,
    # it will not work because Spyne is doing introspection on the
    # function's signature.  I think it would be possible to do
    # something with func.__code__.replace, but this requires deep
    # Python's internal knowledges.

    # pylint: disable=too-many-return-statements
    # pylint: disable=too-many-statements
    # pylint: disable=function-redefined

    if func.__code__.co_argcount == 1:
        @wraps(func)
        def wrapped(self):
            try:
                return func(self)
            except InvalidState as e:
                raise SoapElbeInvalidState()

# Path: elbepack/projectmanager.py
# class ProjectManagerError(Exception):
#     def __init__(self, message):
#         Exception.__init__(self, message)
# 
# class InvalidState(ProjectManagerError):
#     def __init__(self, message):
#         ProjectManagerError.__init__(self, message)
# 
# Path: elbepack/elbexml.py
# class ValidationError(Exception):
#     def __init__(self, validation):
#         Exception.__init__(self)
#         self.validation = validation
# 
#     def __repr__(self):
#         rep = "Elbe XML Validation Error\n"
#         for v in self.validation:
#             rep += (v + '\n')
#         return rep
# 
#     def __str__(self):
#         retval = ""
#         for v in self.validation:
#             retval += (v + '\n')
#         return retval
# 
# Path: elbepack/db.py
# class ElbeDBError(Exception):
#     def __init__(self, message):
#         Exception.__init__(self, message)
# 
# class InvalidLogin(Exception):
#     def __init__(self):
#         Exception.__init__(self, "Invalid login")


# Path: elbepack/daemons/soap/faults.py
from traceback import format_exc
from functools import wraps
from spyne.model.fault import Fault
from elbepack.projectmanager import ProjectManagerError, InvalidState
from elbepack.elbexml import ValidationError
from elbepack.db import ElbeDBError, InvalidLogin



class SoapElbeInvalidState(Fault):
    def __init__(self):
        Fault.__init__(self, faultcode="ElbeInvalidState",
                       faultstring="Project is Busy ! Operation Invalid")


def soap_faults(func):
    """ decorator, which wraps Exceptions to the proper
        Soap Faults, and raises these.
    """

    # Do not edit this code.  Although using *args is tempting here,
    # it will not work because Spyne is doing introspection on the
    # function's signature.  I think it would be possible to do
    # something with func.__code__.replace, but this requires deep
    # Python's internal knowledges.

    # pylint: disable=too-many-return-statements
    # pylint: disable=too-many-statements
    # pylint: disable=function-redefined

    if func.__code__.co_argcount == 1:
        @wraps(func)
        def wrapped(self):
            try:
                return func(self)
            except InvalidState as e:
                raise SoapElbeInvalidState()

            except ProjectManagerError as e: