B
    `                 @   sL   d dl mZ d dlZddlmZmZ ddlmZ G dd de	Z
dd	 ZdS )
    )OrderedDictN   )	urlencodeurlparse)
InvalidURIc               @   s*   e Zd ZdZd
ddZdd Zdd	 ZdS )
PlasterURLa  
    Represents the components of a URL used to locate a
    :class:`plaster.ILoader`.

    :ivar scheme: The name of the loader backend.

    :ivar path: The loader-specific path string.
        This is the entirety of the ``config_uri`` passed to
        :func:`plaster.parse_uri` without the scheme, fragment and options.
        If this value is falsey it is replaced with an empty string.

    :ivar options: A dictionary of options parsed from the query string as
        url-encoded key=value pairs.

    :ivar fragment: A loader-specific default section name.
        This parameter may be used by loaders in scenarios where they provide
        APIs that support a default name. For example, a loader that provides
        ``get_wsgi_app`` may use the fragment to determine the name of the
        section containing the WSGI app if none was explicitly defined.
        If this value is falsey it is replaced with an empty string.

     Nc             C   s8   || _ |sd}|| _|d kr i }|| _|s.d}|| _d S )Nr   )schemepathoptionsfragment)selfr	   r
   r   r    r   S/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/plaster/uri.py__init__#   s    zPlasterURL.__init__c             C   s:   d | }| jr"|dt| j 7 }| jr6|d| j 7 }|S )Nz{0.scheme}://{0.path}?#)formatr   r   r   )r   resultr   r   r   __str__/   s    
zPlasterURL.__str__c             C   s
   d | S )NzPlasterURL('{0}'))r   )r   r   r   r   __repr__7   s    zPlasterURL.__repr__)r   Nr   )__name__
__module____qualname____doc__r   r   r   r   r   r   r   r      s   
r   c             C   s  t | tr| S tj| }|r&d|  } t| }tjd|j|jdddd }|	drd|dd }|j
rv|sv|j
}n2tj|d }|	dr|dd }|rd	| }|jr|jnd}t }|r|t| |jr|jnd}|st| d
| t||||dS )a  
    Parse the ``config_uri`` into a :class:`plaster.PlasterURL` object.

    ``config_uri`` can be a relative or absolute file path such as
    ``development.ini`` or ``/path/to/development.ini``. The file must have
    an extension that can be handled by a :class:`plaster.ILoader`
    registered with the system.

    Alternatively, ``config_uri`` may be a :rfc:`1738`-style string.

    zdummy://r   )r	   netlocr
   paramsqueryr   z//   Nr   .zfile+zGCould not determine the loader scheme for the supplied config_uri "{0}")r	   r
   r   r   )
isinstancer   osr
   isabsr   ParseResultr   geturl
startswithr	   splitextr   r   update	parse_qslr   r   r   )Z
config_urir"   partsr
   r	   r   r   r   r   r   r   	parse_uri;   sH    




r*   )collectionsr   os.pathr!   compatr   r   
exceptionsr   objectr   r*   r   r   r   r   <module>   s
   0