ó
P'^c           @@  sĄ   d  Z  d d l m Z d d l m Z d d l m Z d d l m Z d d l	 m
 Z
 m Z d d l m Z d d	 d
 g Z e
 d  Z d e f d     YZ d	 e f d     YZ d   Z d S(   s}   
    celery.routes
    ~~~~~~~~~~~~~

    Contains utilities for working with task routers,
    (:setting:`CELERY_ROUTES`).

i    (   t   absolute_import(   t   QueueNotFound(   t   string_t(   t   lpmerge(   t   firstmethodt   mlazy(   t   instantiatet   MapRoutet   Routert   preparet   route_for_taskc           B@  s    e  Z d  Z d   Z d   Z RS(   s(   Creates a router out of a :class:`dict`.c         C@  s   | |  _  d  S(   N(   t   map(   t   selfR   (    (    s3   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/routes.pyt   __init__   s    c         O@  sL   y t  |  j |  SWn0 t k
 r( n  t k
 rG i |  j | d 6SXd  S(   Nt   queue(   t   dictR   t   KeyErrort
   ValueError(   R   t   taskt   argst   kwargs(    (    s3   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/routes.pyR
      s    (   t   __name__t
   __module__t   __doc__R   R
   (    (    (    s3   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/routes.pyR      s   	c           B@  sD   e  Z d d e d d   Z d i  d  Z d   Z d d d  Z RS(   c         C@  sL   | |  _  | d  k r i  n | |  _ | d  k r6 g  n | |  _ | |  _ d  S(   N(   t   appt   Nonet   queuest   routest   create_missing(   R   R   R   R   R   (    (    s3   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/routes.pyR   (   s    	c         C@  s   |  j  |  } |  j rL |  j | | |  } | rL t |  j  |  |  Sn  d | k r| t |  j  |  j j j  |  } n  | S(   NR   (   t   expand_destinationR   t   lookup_routeR   R   t   conft   CELERY_DEFAULT_QUEUE(   R   t   optionsR   R   R   t   route(    (    s3   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/routes.pyR"   /   s    		c         C@  s   t  | t  r | i  } } n | j d d   } | r~ y |  j | } Wn& t k
 rp t d j |    n X| | d <n  | S(   NR   s&   Queue {0!r} missing from CELERY_QUEUES(   t
   isinstanceR   t   popR   R   R   R   t   format(   R   R"   R   t   Q(    (    s3   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/routes.pyR   :   s    c         C@  s   t  |  j | | |  S(   N(   t   _first_routeR   (   R   R   R   R   (    (    s3   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/routes.pyR   M   s    N(    (   R   R   R   t   FalseR   R"   R   R   (    (    (    s3   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/routes.pyR   &   s
   	c         C@  sW   d   } |  d k r d St |  t t f  s: |  f }  n  g  |  D] } | |  ^ qA S(   s-   Expands the :setting:`CELERY_ROUTES` setting.c         S@  s9   t  |  t  r t |   St  |  t  r5 t t |   S|  S(   N(   R#   R   R   R   R   R   (   R"   (    (    s3   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/routes.pyt   expand_routeT   s
    
N(    (   R   R#   t   listt   tuple(   R   R)   R"   (    (    s3   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/routes.pyR	   Q   s    	N(   R   t
   __future__R    t   celery.exceptionsR   t   celery.fiveR   t   celery.utilsR   t   celery.utils.functionalR   R   t   celery.utils.importsR   t   __all__R'   t   objectR   R   R	   (    (    (    s3   /tmp/pip-unpacked-wheel-gV1wwp/celery/app/routes.pyt   <module>	   s   +