# Path: git_trac/trac_error.py
# class TracInternalError(TracError):
#     def __init__(self, fault):
#         self._fault = fault
#         self.faultCode = fault.faultCode
# 
#     def __str__(self):
#         return str(self._fault)
# 
# class TracAuthenticationError(TracError):
#     def __init__(self):
#         TracError.__init__(self, 'Authentication with trac server failed.')
# 
# class TracConnectionError(TracError):
#     def __init__(self, msg=None):
#         if msg is None:
#             TracError.__init__(self, 'Connection to trac server failed.')
#         else:
#             TracError.__init__(self, msg)


    from xmlrpclib import SafeTransport, Fault
    from xmlrpc.client import SafeTransport, Fault
from .trac_error import (
    TracInternalError, TracAuthenticationError, TracConnectionError)
"""
HTTP transport to the Trac server using token-based authentication on each
request.
"""

try:
except ImportError:




class TokenAuthenticatedTransport(SafeTransport, object):
    def __init__(self, token):
        super(TokenAuthenticatedTransport, self).__init__()
        self._token = token

    def single_request(self, host, handler, request_body, verbose):
        """
        Issue an XML-RPC request.
        """

        try:
            return super(TokenAuthenticatedTransport, self).single_request(
                    host, handler, request_body, verbose)
        except Fault as e:
            raise TracInternalError(e)
        except IOError as e:
            if hasattr(e, 'code') and e.code == 401:

# Path: git_trac/trac_error.py
# class TracInternalError(TracError):
#     def __init__(self, fault):
#         self._fault = fault
#         self.faultCode = fault.faultCode
# 
#     def __str__(self):
#         return str(self._fault)
# 
# class TracAuthenticationError(TracError):
#     def __init__(self):
#         TracError.__init__(self, 'Authentication with trac server failed.')
# 
# class TracConnectionError(TracError):
#     def __init__(self, msg=None):
#         if msg is None:
#             TracError.__init__(self, 'Connection to trac server failed.')
#         else:
#             TracError.__init__(self, msg)


# Path: git_trac/token_transport.py
    from xmlrpclib import SafeTransport, Fault
    from xmlrpc.client import SafeTransport, Fault
from .trac_error import (
    TracInternalError, TracAuthenticationError, TracConnectionError)

"""
HTTP transport to the Trac server using token-based authentication on each
request.
"""

try:
except ImportError:




class TokenAuthenticatedTransport(SafeTransport, object):
    def __init__(self, token):
        super(TokenAuthenticatedTransport, self).__init__()
        self._token = token

    def single_request(self, host, handler, request_body, verbose):
        """
        Issue an XML-RPC request.
        """

        try:
            return super(TokenAuthenticatedTransport, self).single_request(
                    host, handler, request_body, verbose)
        except Fault as e:
            raise TracInternalError(e)
        except IOError as e:
            if hasattr(e, 'code') and e.code == 401:

                raise TracAuthenticationError()