def __init__(self, client, on_response=None, on_headers=None,
                 on_progress=None, on_ssl_error=None, on_error=None,
                 timeout=None, max_redirects=None, keep_alive=None, auth=None,
                 headers=None, cookies=None, verify_ssl=None,
                 ssl_options=None):
        """ Initialize the Session. """
        # Store the client and parent.
        if isinstance(client, Session):
            self.parent = parent = client
            self.client = client = self.parent.client
        else:
            self.client = client
            parent = client._sessions[-1] if client._sessions else None
            self.parent = parent

        # Setup our default settings.
        if on_response is None:
            on_response = parent.on_response if parent else client.on_response
        if on_headers is None:
            on_headers = parent.on_headers if parent else client.on_headers
        if on_progress is None:
            on_progress = parent.on_progress if parent else client.on_progress
        if on_ssl_error is None:
            if parent:
                on_ssl_error = parent.on_ssl_error
            else:
                on_ssl_error = client.on_ssl_error
        if on_error is None:
            on_error = parent.on_error if parent else client.on_error
        if timeout is None:
            timeout = parent.timeout if parent else 30
        if max_redirects is None:
            max_redirects = parent.max_redirects if parent else 10
        if keep_alive is None:
            keep_alive = parent.keep_alive if parent else True
        if auth is None:
            auth = parent.auth if parent else None
        if headers is None:
            headers = {}
            if parent and parent.headers:
                headers.update(parent.headers)
        if verify_ssl is None:
            verify_ssl = parent.verify_ssl if parent else False
        if ssl_options is None:
            ssl_options = parent.ssl_options if parent else None

        # Do some logic about SSL verification.
        if verify_ssl:
            if not ssl_options:
                # This logic comes from requests.
                loc = None
                if verify_ssl is not True:
                    loc = verify_ssl
                if not loc:
                    loc = os.environ.get('PANTS_CA_BUNDLE')
                if not loc:
                    loc = os.environ.get('CURL_CA_BUNDLE')
                if not loc:
                    try:
                        import certifi
                        loc = certifi.where()
                    except __HOLE__:
                        pass
                if not loc:
                    raise RuntimeError("Cannot find certificates for SSL "
                                       "verification.")
                ssl_options = {'ca_certs': loc, 'cert_reqs': ssl.CERT_REQUIRED}

            # Make sure we've got backports.ssl_match_hostname
            if not match_hostname:
                raise RuntimeError("Cannot verify SSL certificates without "
                                   "the package backports.ssl_match_hostname.")

        # Ensure the cookies are a cookiejar.
        if cookies is None:
            cookies = Cookie.SimpleCookie()
        elif isinstance(cookies, dict):
            cookies = Cookie.SimpleCookie(cookies)

        # Store our settings now.
        self.on_response = on_response
        self.on_headers = on_headers
        self.on_progress = on_progress
        self.on_ssl_error = on_ssl_error
        self.on_error = on_error
        self.timeout = timeout
        self.max_redirects = max_redirects
        self.keep_alive = keep_alive
        self.auth = auth
        self.headers = headers
        self.cookies = cookies
        self.verify_ssl = verify_ssl
        self.ssl_options = ssl_options


    ##### Session Generation ##################################################
dataset/ETHPy150Open ecdavis/pants/pants/http/client.py/Session.__init__