�
Ʋ�a� � �� � d Z eZg d�Z ddlmZ ddlZddlm Z dZ
dZdZd Z
d
ZdZdZd
ZdZdZdZdZdZdZ ee
e
eeee
e�� Z eeeeeeee�� Zd� Zd� Zd� Zd� Zy# e$ r ddlmZ Y �^w xY w)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)�URIzhttps://api.launchpad.net/z$https://api.qastaging.launchpad.net/z"https://api.staging.launchpad.net/zhttps://api.launchpad.test/zhttps://api.dogfood.paddev.net/zhttp://api.launchpad.test:8085/zhttps://launchpad.net/z https://qastaging.launchpad.net/zhttps://staging.launchpad.net/zhttps://launchpad.test/zhttps://dogfood.paddev.net/zhttp://launchpad.test:8085/zhttps://api.edge.launchpad.net/zhttps://edge.launchpad.net/)�
production�edge� qastaging�staging�dogfood�dev�test_devc � � | dk( rt j dt � | |v r|| S t | � \ }}}}}}|dk7 r|dk7 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�.�7�V�V�T�:�u�h�
��|��"���� �G�$�N�� � c �8 � | t k( rd} 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_roots r r r g s � � �(�(����l�M�:�:r c �8 � | t k( rd} t | t � S )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_roots r r r t s � � �=� ����h� �2�2r c � � t | � } t | � }d|_ |j j ddd� |_ t |j
� � }|S )zeTurn a service root URL into a web root URL.
This is done heuristically, not with a lookup.
r zapi.� )r r r �host�replace�str�ensureSlash)r# �web_root_urir' |