
    N}bgm                         d Z ddlZddlmZ ddlmZmZmZ ddlm	Z	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:`GeocoderDotUS` geocoder.
    N)	b64encode)	urlencodepy3kRequest)GeocoderDEFAULT_FORMAT_STRINGDEFAULT_TIMEOUT)Location)ConfigurationError)loggerjoin_filter)GeocoderDotUSc                   T     e Zd ZdZddeeddf fd	ZddZed             Z	d Z
 xZS )	r   z
    GeocoderDotUS geocoder, documentation at:
        http://geocoder.us/

    Note that GeocoderDotUS does not support SSL.
    Nc                     t          t          |                               ||||           |s|r"|r|st          d          d| _        d| _        nd| _        d| _        || _        || _        dS )a  
        :param str username:

        :param str password:

        :param str format_string: String containing '%s' where the
            string to geocode should be interpolated before querying the
            geocoder. For example: '%s, Mountain View, CA'. The default
            is just '%s'.

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

            .. versionadded:: 0.97

        :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
        )format_stringtimeoutproxies
user_agentz)Username and password must both specifiedTz*http://geocoder.us/member/service/namedcsvFz#http://geocoder.us/service/namedcsvN)superr   __init__r   authenticatedapiusernamepassword)selfr   r   r   r   r   r   	__class__s          i/home/e360mart.nyusoft.in/public_html/e360mart_env/lib/python3.11/site-packages/geopy/geocoders/dot_us.pyr   zGeocoderDotUS.__init__   s    H 	mT""++''V` 	, 	
 	
 	
  		=x 		=  (?   "&DCDHH!&D<DH      Tc                      j         |z  }d                     j        t          d|i          f          }t	          j        d j        j        |           t          | 	                                          } 
                    ||d          }t          r'|                                                    d          n|                                }d t          j        t!          |t"                    s|gn|          D             }t%          |          sd	S |r                     |d
                   S  fd|D             }	d	|	v 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 timeout: Time, in seconds, to wait for the geocoding service
            to respond before raising a :class:`geopy.exc.GeocoderTimedOut`
            exception. Set this only if you wish to override, on this call
            only, the value set during the geocoder's initialization.

            .. versionadded:: 0.97
        ?addressz%s.geocode: %s)headersT)r   rawutf-8c                     g | ]}|S  r&   ).0rs     r   
<listcomp>z)GeocoderDotUS.geocode.<locals>.<listcomp>h   s%     
 
 
A
 
 
r   Nr   c                 :    g | ]}                     |          S r&   )_parse_result)r'   resr   s     r   r)   z)GeocoderDotUS.geocode.<locals>.<listcomp>s   s'    @@@#d((--@@@r   )r   joinr   r   r   debugr   __name__r   _get_headers_call_geocoderr   readdecodecsvreader
isinstancelistlenr+   )
r   queryexactly_oner   	query_strurlpagecontentplacesresults
   `         r   geocodezGeocoderDotUS.geocodeQ   s\     &.	hh)Yy,A"B"BCDD%t~'>DDDc4#4#4#6#6777""3T"BB15F$))++$$W---499;;
 
z#-gt#<#<  
 
 
 6{{ 	4 	%%fQi000@@@@@@@Fv~~tMr   c           
         t          d | D                       }d|v rd|d         v rdS |                    dd          |                    dd          |                    dd          |                    dd          |                    d	d          g}|                    d
d          }|                    dd          }|                    dd          }t          dt          d|          |t          d||g          g          }|                    dd          }|                    dd          }|r!|rt          |          t          |          f}	ndS t	          ||	|          S )zS
        Parse individual results. Different, but lazy actually, so... ok.
        c                     g | ]=}t          |                    d                     dk    (|                    d           >S )=   )r8   split)r'   xs     r   r)   z/GeocoderDotUS._parse_result.<locals>.<listcomp>   s>    CCCaS->->-B-BQWWS\\-B-B-Br   errorzcouldn't findNnumberprefixstreettypesuffixcitystatezipz,  latlong)dictgetr   floatr
   )
r@   placer!   rN   rO   zip_codenamelatitude	longitudelatlons
             r   r+   zGeocoderDotUS._parse_resultx   s~    CC6CCC
 
 e%.00t IIh%%IIh%%IIh%%IIfd##IIh%%
 yy&&		'4((99UD))4W%%eX.//"
   99UD))IIfd++	 		 	8__eI&6&66FF4fe,,,r   c                     i }| j         rpd                    | j        | j        f          }d                    dt	          |                    d                                        d          f          }||d<   |S )N:rQ   Basicr$   Authorization)r   r-   r   r   r   encoder3   )r   r"   username_passwordauths       r   r0   zGeocoderDotUS._get_headers   s     	, #$-)G H H88+227;;<<CCGLL  D (,GO$r   )TN)r/   
__module____qualname____doc__r   r	   r   rA   staticmethodr+   r0   __classcell__)r   s   @r   r   r      s          /#2! 2! 2! 2! 2! 2!h% % % %N $- $- \$-L	 	 	 	 	 	 	r   r   )rf   r4   base64r   geopy.compatr   r   r   geopy.geocoders.baser   r   r	   geopy.locationr
   	geopy.excr   
geopy.utilr   r   __all__r   r&   r   r   <module>rp      s     


       1 1 1 1 1 1 1 1 1 1         
 $ # # # # # ( ( ( ( ( ( * * * * * * * * S S S S SH S S S S Sr   