
    &g                       S r SSKJr  SSKJrJr  SSKJr  SSKJ	r	  SSK
JrJr  SSKJrJr  SSKJrJrJrJrJrJrJrJrJr  S	r\S
S	S
SSS4                 SS jjr\S
S	S
SSS4                 SS jjrg)z*Tools to parse and validate a MongoDB URI.    )annotations)AnyOptional)unquote_plus)_SrvResolver)SRV_SERVICE_NAME_CaseInsensitiveDictionary)ConfigurationError
InvalidURI)	_ALLOWED_TXT_OPTSDEFAULT_PORTSCHEME
SCHEME_LENSRV_SCHEME_LEN_check_options_validate_urisplit_hostssplit_optionsFTNc                ~   #    [        XX#XG5      nUR                  [        U UUUUUUU5      I Sh  vN 5        U$  N
7f)a  Parse and validate a MongoDB URI.

Returns a dict of the form::

    {
        'nodelist': <list of (host, port) tuples>,
        'username': <username> or None,
        'password': <password> or None,
        'database': <database name> or None,
        'collection': <collection name> or None,
        'options': <dict of MongoDB URI options>,
        'fqdn': <fqdn of the MongoDB+SRV URI> or None
    }

If the URI scheme is "mongodb+srv://" DNS SRV and TXT lookups will be done
to build nodelist and options.

:param uri: The MongoDB URI to parse.
:param default_port: The port number to use when one wasn't specified
      for a host in the URI.
:param validate: If ``True`` (the default), validate and
      normalize all options. Default: ``True``.
:param warn: When validating, if ``True`` then will warn
      the user then ignore any invalid options or values. If ``False``,
      validation will error when options are unsupported or values are
      invalid. Default: ``False``.
:param normalize: If ``True``, convert names of URI options
      to their internally-used names. Default: ``True``.
:param connect_timeout: The maximum time in milliseconds to
      wait for a response from the DNS server.
:param srv_service_name: A custom SRV service name

.. versionchanged:: 4.6
   The delimiting slash (``/``) between hosts and connection options is now optional.
   For example, "mongodb://example.com?tls=true" is now a valid URI.

.. versionchanged:: 4.0
   To better follow RFC 3986, unquoted percent signs ("%") are no longer
   supported.

.. versionchanged:: 3.9
    Added the ``normalize`` parameter.

.. versionchanged:: 3.6
    Added support for mongodb+srv:// URIs.

.. versionchanged:: 3.5
    Return the original value of the ``readPreference`` MongoDB URI option
    instead of the validated read preference mode.

.. versionchanged:: 3.1
    ``warn`` added so invalid options can be ignored.
N)r   update
_parse_srv)	uridefault_portvalidatewarn	normalizeconnect_timeoutsrv_service_namesrv_max_hostsresults	            dC:\Suresh\moveshuttle\MDcreated\moveengine\venv\Lib\site-packages\pymongo/asynchronous/uri_parser.py	parse_urir"   (   sS     ~ 3hiWF
MM	
 		
 M		
s   .=;=c                  #    U R                  [        5      (       a  SnU [        S  n	OSnU [        S  n	[	        5       n
U	R                  S5      u  pnSU;   a  UR                  S5      u  n  nOUnU(       a  U
R                  [        XX45      5        Uc  U
R                  S[        5      nSU;   a  UR                  S5      u    pOUn[        U5      nU=(       d    U
R                  S5      nU(       Ga1  [        US S9nUS	   u  nnU=(       d    U
R                  S
5      n[        UXVU5      nUR                  5       I S h  vN nUR                  5       I S h  vN nU(       aV  [        UX#U5      n[!        U5      ["        -
  (       a  [%        S5      eUR'                  5        H  u  nnUU
;  d  M  UU
U'   M     U
R                  S5      (       a  U(       a  [)        S5      eU
R                  S5      (       a  U(       a  [)        S5      eSU
;  a  SU
;  a  U(       a  SOSU
S'   O	[        XS9n[+        UU
5        UU
S.$  N N7f)NFT?/srvServiceName@srvMaxHosts)r   r   connectTimeoutMSzDOnly authSource, replicaSet, and loadBalanced are supported from DNSloadBalancedz0You cannot specify loadBalanced with srvMaxHosts
replicaSetz.You cannot specify replicaSet with srvMaxHoststlsssltrue)nodelistoptions)
startswithr   r   r   r	   	partitionr   r   getr   
rpartitionr   r   r   	get_hostsget_optionssetr   r
   itemsr   r   )r   r   r   r   r   r   r   r   is_srvscheme_freer0   host_plus_db_part_opts	host_parthostsnodesfqdnportdns_resolverdns_optionsparsed_dns_optionsoptvals                           r!   r   r   w   s-     ~~f*+&./*(*G!,!6!6s!;$
+55c:	1a%	}TTEF";;'79IJ
i**3/1eE!?W[[%?ME51X
d *LW[[9K-L#D/][",,..(4466!.{HI!V%&)::(Z  /446Sg%#&GCL 7 ;;~&&=OPP;;|$$MNNE$8%-T6GENE=5'"  - /6s,   D?II IIAI2BII)r   strr   Optional[int]r   boolr   rJ   r   rJ   r   zOptional[float]r   zOptional[str]r   rI   returnzdict[str, Any])__doc__
__future__r   typingr   r   urllib.parser   !pymongo.asynchronous.srv_resolverr   pymongo.commonr   r	   pymongo.errorsr
   r   pymongo.uri_parser_sharedr   r   r   r   r   r   r   r   r   _IS_SYNCr"   r        r!   <module>rW      s+    1 "   % : G 9
 
 
 
 #/'+&*#'L	LL L 	L
 L %L $L !L Lb #/'+&*#'E	EE E 	E
 E %E $E !E ErV   