o
    Æ²…aª  ã                	   @   sÜ   d Z eZg d¢ZzddlmZ W n ey   ddlmZ Y nw ddlZddlm	Z	 dZ
dZdZd	Zd
ZdZdZdZdZdZdZdZdZdZee
e
eeeeed�Zeeeeeeeed�Zdd„ Zdd„ Zdd„ Zdd„ ZdS )z¡Launchpad-specific URIs and convenience lookup functions.

The code in this module lets users say "staging" when they mean
"https://api.staging.launchpad.net/".
)Úlookup_service_rootÚlookup_web_rootÚweb_root_for_service_rooté    )ÚurlparseN)ÚURIzhttps://api.launchpad.net/z$https://api.qastaging.launchpad.net/z"https://api.staging.launchpad.net/zhttps://api.launchpad.test/zhttps://api.dogfood.paddev.net/zhttp://api.launchpad.test:8085/zhttps://launchpad.net/z https://qastaging.launchpad.net/zhttps://staging.launchpad.net/zhttps://launchpad.test/zhttps://dogfood.paddev.net/zhttp://launchpad.test:8085/zhttps://api.edge.launchpad.net/zhttps://edge.launchpad.net/)Ú
productionÚedgeÚ	qastagingÚstagingÚdogfoodÚdevÚtest_devc                 C   sX   | dkr
t  dt¡ | |v r||  S t| ƒ\}}}}}}|dkr&|dkr&| S td|  ƒ‚)z3Dereference what might a URL or an alias for a URL.r   zCLaunchpad edge server no longer exists. Using 'production' instead.Ú z:%s is not a valid URL or an alias for any Launchpad server)ÚwarningsÚwarnÚDeprecationWarningr   Ú
ValueError)ÚrootÚaliasesÚschemeÚnetlocÚpathÚ
parametersÚqueryÚfragment© r   ú3/usr/lib/python3/dist-packages/launchpadlib/uris.pyÚ_dereference_aliasO   s   ûÿr   c                 C   ó   | t krd} t| tƒS )zÌDereference an alias to a service root.

    A recognized server alias such as "staging" gets turned into the
    appropriate URI. A URI gets returned as is. Any other string raises a
    ValueError.
    r   )ÚEDGE_SERVICE_ROOTr   Úservice_roots)Úservice_rootr   r   r   r   g   ó   
r   c                 C   r   )zÌDereference an alias to a website root.

    A recognized server alias such as "staging" gets turned into the
    appropriate URI. A URI gets returned as is. Any other string raises a
    ValueError.
    r   )ÚEDGE_WEB_ROOTr   Ú	web_roots)Úweb_rootr   r   r   r   t   r"   r   c                 C   s8   t | ƒ} t| ƒ}d|_|j ddd¡|_t| ¡ ƒ}|S )zeTurn a service root URL into a web root URL.

    This is done heuristically, not with a lookup.
    r   zapi.é   )r   r   r   ÚhostÚreplaceÚstrÚensureSlash)r!   Úweb_root_urir%   r   r   r   r   �   s   r   )Ú__doc__ÚtypeÚ__metaclass__Ú__all__Úurllib.parser   ÚImportErrorr   Úlazr.urir   ÚLPNET_SERVICE_ROOTÚQASTAGING_SERVICE_ROOTÚSTAGING_SERVICE_ROOTÚDEV_SERVICE_ROOTÚDOGFOOD_SERVICE_ROOTÚTEST_DEV_SERVICE_ROOTÚLPNET_WEB_ROOTÚQASTAGING_WEB_ROOTÚSTAGING_WEB_ROOTÚDEV_WEB_ROOTÚDOGFOOD_WEB_ROOTÚTEST_DEV_WEB_ROOTr   r#   Údictr    r$   r   r   r   r   r   r   r   r   Ú<module>   s\   ÿùù