# Path: geopy/exc.py
# class GeocoderParseError(GeocoderServiceError):
#     """
#     Geopy could not parse the service's response. This is probably due
#     to a bug in geopy.
#     """
# 
# class GeocoderServiceError(GeopyError):
#     """
#     There was an exception caused when calling the remote geocoding service,
#     and no more specific exception could be raised by geopy. When calling
#     geocoders' ``geocode`` or `reverse` methods, this is the most generic
#     exception that can be raised, and any non-geopy exception will be caught
#     and turned into this. The exception's message will be that of the
#     original exception.
#     """
# 
# class GeocoderTimedOut(GeocoderServiceError, TimeoutError):
#     """
#     The call to the geocoding service was aborted because no response
#     has been received within the ``timeout`` argument of either
#     the geocoding class or, if specified, the method call.
#     Some services are just consistently slow, and a higher timeout
#     may be needed to use them.
#     """
# 
# class GeocoderUnavailable(GeocoderServiceError, IOError):
#     """
#     Either it was not possible to establish a connection to the remote
#     geocoding service, or the service responded with a code indicating
#     it was unavailable.
#     """
# 
# class GeopyError(Exception):
#     """
#     Geopy-specific exceptions are all inherited from GeopyError.
#     """
# 
# Path: geopy/util.py
# NUMBER_TYPES = (int, float, Decimal)
# def pairwise(seq):
# def join_filter(sep, seq, pred=bool):
# def get_version():


import abc
import asyncio
import contextlib
import email
import json
import time
import warnings
    import requests
    import aiohttp
    import aiohttp.client_exceptions
    import yarl
            import requests.packages.urllib3 as urllib3
            import urllib3
from socket import timeout as SocketTimeout
from ssl import SSLError
from urllib.error import HTTPError
from urllib.parse import urlparse
from urllib.request import (
    HTTPSHandler,
    ProxyHandler,
    Request,
    URLError,
    build_opener,
    getproxies,
)
from geopy.exc import (
    GeocoderParseError,
    GeocoderServiceError,
    GeocoderTimedOut,
    GeocoderUnavailable,
    GeopyError,
)
from geopy.util import logger
    from requests.adapters import HTTPAdapter as RequestsHTTPAdapter

    def get_text(self, url, *, timeout, headers):
        resp = self._request(url, timeout=timeout, headers=headers)
        return resp.text

    def get_json(self, url, *, timeout, headers):
        resp = self._request(url, timeout=timeout, headers=headers)
        try:
            return resp.json()
        except ValueError:
            raise GeocoderParseError(
                "Could not deserialize using deserializer:\n%s" % resp.text
            )

    def _request(self, url, *, timeout, headers):
        try:
            resp = self.session.get(url, timeout=timeout, headers=headers)
        except Exception as error:
            message = str(error)
            if isinstance(error, SocketTimeout):
                raise GeocoderTimedOut("Service timed out")
            elif isinstance(error, SSLError):
                if "timed out" in message:
                    raise GeocoderTimedOut("Service timed out")
            elif isinstance(error, requests.ConnectionError):
                if "unauthorized" in message.lower():
                    raise GeocoderServiceError(message)
                else:
                    raise GeocoderUnavailable(message)
            elif isinstance(error, requests.Timeout):

# Path: geopy/exc.py
# class GeocoderParseError(GeocoderServiceError):
#     """
#     Geopy could not parse the service's response. This is probably due
#     to a bug in geopy.
#     """
# 
# class GeocoderServiceError(GeopyError):
#     """
#     There was an exception caused when calling the remote geocoding service,
#     and no more specific exception could be raised by geopy. When calling
#     geocoders' ``geocode`` or `reverse` methods, this is the most generic
#     exception that can be raised, and any non-geopy exception will be caught
#     and turned into this. The exception's message will be that of the
#     original exception.
#     """
# 
# class GeocoderTimedOut(GeocoderServiceError, TimeoutError):
#     """
#     The call to the geocoding service was aborted because no response
#     has been received within the ``timeout`` argument of either
#     the geocoding class or, if specified, the method call.
#     Some services are just consistently slow, and a higher timeout
#     may be needed to use them.
#     """
# 
# class GeocoderUnavailable(GeocoderServiceError, IOError):
#     """
#     Either it was not possible to establish a connection to the remote
#     geocoding service, or the service responded with a code indicating
#     it was unavailable.
#     """
# 
# class GeopyError(Exception):
#     """
#     Geopy-specific exceptions are all inherited from GeopyError.
#     """
# 
# Path: geopy/util.py
# NUMBER_TYPES = (int, float, Decimal)
# def pairwise(seq):
# def join_filter(sep, seq, pred=bool):
# def get_version():


# Path: geopy/adapters.py
import abc
import asyncio
import contextlib
import email
import json
import time
import warnings
    import requests
    import aiohttp
    import aiohttp.client_exceptions
    import yarl
            import requests.packages.urllib3 as urllib3
            import urllib3
from socket import timeout as SocketTimeout
from ssl import SSLError
from urllib.error import HTTPError
from urllib.parse import urlparse
from urllib.request import (
    HTTPSHandler,
    ProxyHandler,
    Request,
    URLError,
    build_opener,
    getproxies,
)
from geopy.exc import (
    GeocoderParseError,
    GeocoderServiceError,
    GeocoderTimedOut,
    GeocoderUnavailable,
    GeopyError,
)
from geopy.util import logger
    from requests.adapters import HTTPAdapter as RequestsHTTPAdapter


    def get_text(self, url, *, timeout, headers):
        resp = self._request(url, timeout=timeout, headers=headers)
        return resp.text

    def get_json(self, url, *, timeout, headers):
        resp = self._request(url, timeout=timeout, headers=headers)
        try:
            return resp.json()
        except ValueError:
            raise GeocoderParseError(
                "Could not deserialize using deserializer:\n%s" % resp.text
            )

    def _request(self, url, *, timeout, headers):
        try:
            resp = self.session.get(url, timeout=timeout, headers=headers)
        except Exception as error:
            message = str(error)
            if isinstance(error, SocketTimeout):
                raise GeocoderTimedOut("Service timed out")
            elif isinstance(error, SSLError):
                if "timed out" in message:
                    raise GeocoderTimedOut("Service timed out")
            elif isinstance(error, requests.ConnectionError):
                if "unauthorized" in message.lower():
                    raise GeocoderServiceError(message)
                else:
                    raise GeocoderUnavailable(message)
            elif isinstance(error, requests.Timeout):

                raise GeocoderTimedOut("Service timed out")