
    ob	              	           d Z ddlmZmZmZ ddlZddlZddlZddlZddl	m
Z
mZ ddlmZ ej                  rddlmZmZ  G d d	 ej"                  d	g d
            Z ej&                  dej(                        Zd Zy)z9Function to parse FS URLs in to their constituent parts.
    )absolute_importprint_functionunicode_literalsN)parse_qsunquote   )
ParseError)OptionalTextc                       e Zd ZdZy)ParseResulta+  A named tuple containing fields of a parsed FS URL.

    Attributes:
        protocol (str): The protocol part of the url, e.g. ``osfs``
            or ``ftp``.
        username (str, optional): A username, or `None`.
        password (str, optional): A password, or `None`.
        resource (str): A *resource*, typically a domain and path, e.g.
            ``ftp.example.org/dir``.
        params (dict): A dictionary of parameters extracted from the
            query string.
        path (str, optional): A path within the filesystem, or `None`.

    N)__name__
__module____qualname____doc__     1/usr/lib/python3/dist-packages/fs/opener/parse.pyr   r      s    r   r   )protocolusernamepasswordresourceparamspathz>
^
(.*?)
:\/\/

(?:
(?:(.*?)@(.*?))
|(.*?)
)

(?:
!(.*?)$
)*$
c           	         t         j                  |       }|t        dj                  |             |j	                         \  }}}}}|sd}d}|}	n-|j                  d      \  }}
}t        |      }t        |      }|}	|	j                  d      \  }	}}t        |	      }|rBt        |d      }t        j                  |      D ci c]  \  }}|t        |d          }}}ni }t        ||||||      S c c}}w )a  Parse a Filesystem URL and return a `ParseResult`.

    Arguments:
        fs_url (str): A filesystem URL.

    Returns:
        ~fs.opener.parse.ParseResult: a parse result instance.

    Raises:
        ~fs.errors.ParseError: if the FS URL is not valid.

    Nz{!r} is not a fs2 url:?T)keep_blank_valuesr   )
_RE_FS_URLmatchr	   formatgroups	partitionr   r   six	iteritemsr   )fs_urlr    fs_namecredentialsurl1url2r   r   r   url_has_qsqsr   _paramskvr   s                     r   parse_fs_urlr2   <   s    V$E}077?@@-2\\^*G[$d + 5 5c :!X8$8$mmC(OCs|H26/2}}W/EFtq!!WQqT]"FFw(HfdKK Gs   C4)r   
__future__r   r   r   typingcollectionsrer$   six.moves.urllib.parser   r   errorsr	   TYPE_CHECKINGr
   r   
namedtupler   compileVERBOSEr   r2   r   r   r   <module>r=      sw    I H   	 
 4 	%KJ, RZZ JJ
&#Lr   