
    Ʋa              	           d Z eZg dZ	 ddlmZ 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      Z eeeeeeee      Zd Zd Zd Zd Zy# e$ r	 ddlmZ Y ^w xY w)zLaunchpad-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                     | dk(  rt        j                  dt               | |v r||    S t        |       \  }}}}}}|dk7  r|dk7  r| S t	        d| z        )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fragments           3/usr/lib/python3/dist-packages/launchpadlib/uris.py_dereference_aliasr   O   st    v~. 	
 wt} ;C4.7VVT:uh|" G$N     c                 8    | t         k(  rd} t        | t              S )zDereference 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_roots    r   r   r   g   s     ((lM::r   c                 8    | t         k(  rd} t        | t              S )zDereference 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_roots    r   r   r   t   s     = h	22r   c                     t        |       } t        |       }d|_        |j                  j	                  ddd      |_        t        |j                               }|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'   s      r   r   r      sU    
 '|4L|$LL$))11&"a@L<++-.HOr   )__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   <module>rD      s   " 
"%  1 ? ; 0 8 9 )7 3 (0 1 
 6 -!	$  " 	 	0
;
3
E  "!"s   A! !A/.A/