ó
È{ZMc           @   s)  d  Z  e Z d d d g 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 d e d e d e	 d e
 d e d e d e ƒ Z e d e d e d e d e d e d e d e ƒ Z d „  Z d „  Z d „  Z d  „  Z d S(!   s¡   Launchpad-specific URIs and convenience lookup functions.

The code in this module lets users say "staging" when they mean
"https://api.staging.launchpad.net/".
t   lookup_service_roott   lookup_web_roott   web_root_for_service_rootiÿÿÿÿ(   t   urlparseN(   t   URIs   https://api.launchpad.net/s$   https://api.qastaging.launchpad.net/s"   https://api.staging.launchpad.net/s   https://api.launchpad.dev/s"   https://api.dogfood.launchpad.net/s   http://api.launchpad.dev:8085/s   https://launchpad.net/s    https://qastaging.launchpad.net/s   https://staging.launchpad.net/s   https://launchpad.dev/s   https://dogfood.launchpad.net/s   http://launchpad.dev:8085/s   https://api.edge.launchpad.net/s   https://edge.launchpad.net/t
   productiont   edget	   qastagingt   stagingt   dogfoodt   devt   test_devc         C   s   |  d k r t  j d t ƒ n  |  | k r3 | |  St |  ƒ \ } } } } } } | d k rm | d k rm |  St d |  ƒ ‚ d S(   s3   Dereference what might a URL or an alias for a URL.R   sC   Launchpad edge server no longer exists. Using 'production' instead.t    s:   %s is not a valid URL or an alias for any Launchpad serverN(   t   warningst   warnt   DeprecationWarningR   t
   ValueError(   t   roott   aliasest   schemet   netloct   patht
   parameterst   queryt   fragment(    (    s5   /usr/lib/python2.7/dist-packages/launchpadlib/uris.pyt   _dereference_aliasL   s    	
c         C   s"   |  t  k r d }  n  t |  t ƒ S(   sÌ   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   (   t   EDGE_SERVICE_ROOTR   t   service_roots(   t   service_root(    (    s5   /usr/lib/python2.7/dist-packages/launchpadlib/uris.pyR    ^   s    	c         C   s"   |  t  k r d }  n  t |  t ƒ S(   sÌ   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   (   t   EDGE_WEB_ROOTR   t	   web_roots(   t   web_root(    (    s5   /usr/lib/python2.7/dist-packages/launchpadlib/uris.pyR   k   s    	c         C   sR   t  |  ƒ }  t |  ƒ } d | _ | j j d d d ƒ | _ t | j ƒ  ƒ } | S(   se   Turn a service root URL into a web root URL.

    This is done heuristically, not with a lookup.
    R   s   api.i   (   R    R   R   t   hostt   replacet   strt   ensureSlash(   R   t   web_root_uriR   (    (    s5   /usr/lib/python2.7/dist-packages/launchpadlib/uris.pyR   x   s    	(   t   __doc__t   typet   __metaclass__t   __all__R   R   t   lazr.uriR   t   LPNET_SERVICE_ROOTt   QASTAGING_SERVICE_ROOTt   STAGING_SERVICE_ROOTt   DEV_SERVICE_ROOTt   DOGFOOD_SERVICE_ROOTt   TEST_DEV_SERVICE_ROOTt   LPNET_WEB_ROOTt   QASTAGING_WEB_ROOTt   STAGING_WEB_ROOTt   DEV_WEB_ROOTt   DOGFOOD_WEB_ROOTt   TEST_DEV_WEB_ROOTR   R   t   dictR   R   R   R    R   R   (    (    (    s5   /usr/lib/python2.7/dist-packages/launchpadlib/uris.pyt   <module>   sR   						