Ë
    Ï.f   ã                   ó–   — d Z 	 ddlmZmZ ddlmZ dZddlm	Z	m
Z
 ddlmZ ddlmZ dd	lmZmZ d
Z G d„ de	«      Zy# e$ r dZY Œ3w xY w)z&
:class:`.YahooPlaceFinder` geocoder.
é    )ÚgetÚRequest)ÚOAuth1FT)ÚGeocoderÚDEFAULT_TIMEOUT)ÚGeocoderParseError)ÚLocation)Ústring_compareÚ	text_type)ÚYahooPlaceFinderc                   ól   ‡ — e Zd ZdZeddfˆ fd„	Zed„ «       Zd„ Zed„ «       Z		 	 	 	 	 	 d	d„Z
d
d„Zˆ xZS )r   z†
    Geocoder that utilizes the Yahoo! BOSS PlaceFinder API. Documentation at:
        https://developer.yahoo.com/boss/geo/docs/
    Nc                 óò   •— t         rt        d«      ‚t        t        | �  |||¬«       t        |«      | _        t        |«      | _        t        | j                  | j                  dd¬«      | _	        d| _
        y)aØ  
        :param str consumer_key: Key provided by Yahoo.

        :param str consumer_secret: Secret corresponding to the key
            provided by Yahoo.

        :param int timeout: Time, in seconds, to wait for the geocoding service
            to respond before raising a :class:`geopy.exc.GeocoderTimedOut`
            exception.

        :param dict proxies: If specified, routes this geocoder"s requests
            through the specified proxy. E.g., {"https": "192.0.2.0"}. For
            more information, see documentation on
            :class:`urllib2.ProxyHandler`.

            .. versionadded:: 0.96

        :param str user_agent: Use a custom User-Agent header.

            .. versionadded:: 1.12.0
        zgrequests-oauthlib is needed for YahooPlaceFinder. Install with `pip install geopy -e ".[placefinder]"`.)ÚtimeoutÚproxiesÚ
user_agentz	HMAC-SHA1ÚAUTH_HEADER)Ú
client_keyÚclient_secretÚsignature_methodÚsignature_typez+https://yboss.yahooapis.com/geo/placefinderN)Úrequests_missingÚImportErrorÚsuperr   Ú__init__r   Úconsumer_keyÚconsumer_secretr   ÚauthÚapi)Úselfr   r   r   r   r   Ú	__class__s         €úZC:\Users\user\Documents\project_loop\venv\Lib\site-packages\geopy/geocoders/placefinder.pyr   zYahooPlaceFinder.__init__   sƒ   ø€ õ: ÜðIóð ô 	Ô Ñ.Ø W¸ð 	/ô 	
ô & lÓ3ˆÔÜ(¨Ó9ˆÔÜØ×(Ñ(Ø×.Ñ.Ø(Ø(ô	
ˆŒ	ð Aˆ�ó    c                 ó¶   — |r*| D �cg c]  }t        |j                  d   «      |kD  r|‘Œ! } }|r | D �cg c]  }|j                  d   |v r|‘Œ } }| S c c}w c c}w )z�
        Returns only the results that meet the minimum quality threshold
        and are located in expected countries.
        ÚqualityÚcountrycode)ÚintÚraw)ÚresultsÚmin_qualityÚvalid_country_codesÚlocs       r!   Ú_filtered_resultsz"YahooPlaceFinder._filtered_resultsI   sƒ   € ñ ð #öàÜ�s—w‘w˜yÑ)Ó*¨[Ò8ò ðˆGð ñ ð #öàØ—7‘7˜=Ñ)Ð-@Ñ@ò ðˆGð ð ˆùòùòs
   ‡$A³Ac                 ó:  — 	 |d   d   }t        |«      rt        |j                  dg «      «      sy|d   D �cg c]9  }t        | j                  |«      t	        |d   «      t	        |d   «      f|¬«      ‘Œ; }}|S c c}w # t
        t        f$ r t        d«      ‚w xY w)	zF
        Returns the parsed result of a PlaceFinder API call.
        ÚbossresponseÚplacefinderr(   NÚlatitudeÚ	longitude)r'   z Error parsing PlaceFinder result)Úlenr   r	   ÚhumanizeÚfloatÚKeyErrorÚ
ValueErrorr   )r   Úcontentr/   Úplacer(   s        r!   Ú_parse_responsez YahooPlaceFinder._parse_response_   s¿   € ð	Ià˜Ñ'¨Ñ6ð ô �{Ô#¬3¨{¯©¸yÈ"Ó/MÔ+NØð )¨Ñ3öð ô Ø—M‘M %Ó(Ü˜5 Ñ,Ó-¬u°U¸;Ñ5GÓ/HÐIØöðˆGð ð ˆùòøô œ*Ð%ò 	IÜ$Ð%GÓHÐHð	Iús!   ‚.A? ±A? ¸>A:Á6A? Á:A? Á?Bc                 óZ   — dj                  dD �cg c]  }| |   r| |   ‘Œ c}«      S c c}w )zW
        Returns a human readable representation of a raw PlaceFinder location
        z, )Úline1Úline2Úline3Úline4)Újoin)ÚlocationÚlines     r!   r3   zYahooPlaceFinder.humanizev   s;   € ð
 �y‰yà<ö
àØ˜Š~ð �T‹Nò
ó ð 	ùò 
s   �(c                 ó  — |ddœ}|rd|d<   |rd|d<   |r|dxx   dz  cc<   | j                  | j                  |t        || j                  ¬	«      }	| j	                  |	«      }
|
€y
| j                  |
||«      }
|r|
d   S |
S )aâ  
        Geocode a location query.

        :param str query: The address or query you wish to geocode.

        :param bool exactly_one: Return one result or a list of results, if
            available.

        :param int min_quality:

        :param bool reverse:

        :param valid_country_codes:
        :type valid_country_codes: list or tuple

        :param bool with_timezone: Include the timezone in the response's
            `raw` dictionary (as `timezone`).
        ÚJ)r@   ÚflagsÚRÚgflagsÚ1ÚcountrD   ÚT)r   Ú	requesterÚparamsr   Nr   )Ú_call_geocoderr   r   r   r9   r,   )r   ÚqueryÚexactly_oner   r)   Úreverser*   Úwith_timezonerK   Úresponser(   s              r!   ÚgeocodezYahooPlaceFinder.geocode�   s°   € ð: Øñ
ˆñ
 Ø"ˆF�8ÑÙØ!ˆF�7‰OÙØ�7‹O˜sÑ"‹Oà×&Ñ&Ø�H‰HØÜØØ—‘ð 'ó 
ˆð ×&Ñ& xÓ0ˆØˆ?Øà×(Ñ(ØØØó
ˆñ Ø˜1‘:ÐàˆNr"   c                 ó’   — | j                  |«      }t        |t        «      r|j                  dd«      }| j	                  |||d¬«      S )a¾  
        Returns a reverse geocoded location using Yahoo"s PlaceFinder API.

        :param query: The coordinates for which you wish to obtain the
            closest human-readable addresses.
        :type query: :class:`geopy.point.Point`, list or tuple of (latitude,
            longitude), or string as "%(latitude)s, %(longitude)s"

        :param bool exactly_one: Return one result or a list of results, if
            available.
        ú Ú T)rN   r   rO   )Ú_coerce_point_to_stringÚ
isinstancer
   ÚreplacerR   )r   rM   rN   r   s       r!   rO   zYahooPlaceFinder.reverse¿   sP   € ð ×,Ñ,¨UÓ3ˆÜ�eœ^Ô,Ø—M‘M # rÓ*ˆEØ�|‰|ØØ#ØØð	 ó 
ð 	
r"   )TNr   FNF)TN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ústaticmethodr,   r9   r3   rR   rO   Ú__classcell__)r    s   @r!   r   r      sf   ø„ ñð $ØØõ-Að^ ñó ðò*ð. ñó ðð ØØØØ $Øó<÷|
r"   r   N)r\   Úrequestsr   r   Úrequests_oauthlibr   r   r   Úgeopy.geocoders.baser   r   Ú	geopy.excr   Úgeopy.locationr	   Úgeopy.compatr
   r   Ú__all__r   © r"   r!   ú<module>rg      sS   ðñðß%Ý(ØÐ÷ ;Ý (Ý #ß 2à
 €ô
�xõ 
øð ò ØÒðús   „> ¾AÁA