
    N}bg                          d Z 	 ddlmZmZ ddlmZ dZn# e$ r dZY nw xY w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dS )z&
:class:`.YahooPlaceFinder` geocoder.
    )getRequest)OAuth1FT)GeocoderDEFAULT_TIMEOUT)GeocoderParseError)Location)string_compare	text_type)YahooPlaceFinderc                   x     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| _
        dS )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         n/home/e360mart.nyusoft.in/public_html/e360mart_env/lib/python3.11/site-packages/geopy/geocoders/placefinder.pyr   zYahooPlaceFinder.__init__   s    :  	I   	%%..W 	/ 	
 	
 	
 &l33(99(.((	
 
 
	 A    c                 J    rfd| D             } rfd| D             } | S )z
        Returns only the results that meet the minimum quality threshold
        and are located in expected countries.
        c                 P    g | ]"}t          |j        d                    k     |#S )quality)intraw).0locmin_qualitys     r!   
<listcomp>z6YahooPlaceFinder._filtered_results.<locals>.<listcomp>P   s=       swy)**[88 888r"   c                 2    g | ]}|j         d          v |S )countrycoder'   )r(   r)   valid_country_codess     r!   r+   z6YahooPlaceFinder._filtered_results.<locals>.<listcomp>W   s6       7=)-@@@ @@@r"    )resultsr*   r/   s    ``r!   _filtered_resultsz"YahooPlaceFinder._filtered_resultsI   so      	   "  G  	   "  G r"   c                      	 |d         d         }t          |          r#t          |                    dg                     sdS  fd|d         D             }n$# t          t          f$ r t	          d          w xY w|S )zF
        Returns the parsed result of a PlaceFinder API call.
        bossresponseplacefinderr1   Nc           
          g | ]O}t                              |          t          |d                    t          |d                   f|          PS )latitude	longituder.   )r	   humanizefloat)r(   placer   s     r!   r+   z4YahooPlaceFinder._parse_response.<locals>.<listcomp>i   sn         MM%((5,--uU;5G/H/HI    r"   z Error parsing PlaceFinder result)lenr   KeyError
ValueErrorr   )r   contentr5   r1   s   `   r!   _parse_responsez YahooPlaceFinder._parse_response_   s    	I'6  {## 3{y"/M/M+N+N t    )3  GG *% 	I 	I 	I$%GHHH	I s   A A A !A;c                 F     d                      fddD                       S )zW
        Returns a human readable representation of a raw PlaceFinder location
        z, c                 0    g | ]}|         
|         S r0   r0   )r(   linelocations     r!   r+   z-YahooPlaceFinder.humanize.<locals>.<listcomp>{   s7     
 
 
~
TN
 
 
r"   )line1line2line3line4)join)rD   s   `r!   r9   zYahooPlaceFinder.humanizev   sA    
 yy 
 
 
 
<
 
 
   	r"   Tr   Fc                    |dd}|rd|d<   |rd|d<   |r|dxx         dz  cc<   |                      | j        |t          || j        	          }	|                     |	          }
|
d
S |                     |
||          }
|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)rD   flagsRgflags1countrL   T)r   	requesterparamsr   Nr   )_call_geocoderr   r   r   r@   r2   )r   queryexactly_oner   r*   reverser/   with_timezonerS   responser1   s              r!   geocodezYahooPlaceFinder.geocode   s    : 
 

  	#"F8 	"!F7O 	#7OOOs"OOO&&H ' 
 
 &&x00?4((
 
  	1:Nr"   c                     |                      |          }t          |t                    r|                    dd          }|                     |||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)rV   r   rW   )_coerce_point_to_string
isinstancer
   replacerZ   )r   rU   rV   r   s       r!   rW   zYahooPlaceFinder.reverse   sc     ,,U33e^,, 	+MM#r**E||#	  
 
 	
r"   )TNr   FNF)TN)__name__
__module____qualname____doc__r   r   staticmethodr2   r@   r9   rZ   rW   __classcell__)r    s   @r!   r   r      s          $-A -A -A -A -A -A^   \*  .   \  $< < < <|
 
 
 
 
 
 
 
r"   r   N)rd   requestsr   r   requests_oauthlibr   r   r   geopy.geocoders.baser   r   	geopy.excr   geopy.locationr	   geopy.compatr
   r   __all__r   r0   r"   r!   <module>rn      s   %%%%%%%%((((((    ; : : : : : : : ( ( ( ( ( ( # # # # # # 2 2 2 2 2 2 2 2
 
 
 
 
 
x 
 
 
 
 
s    